@journeeze/sdk 0.1.0 → 0.2.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/AGENTS.md +2 -2
- package/CHANGELOG.md +13 -1
- package/LICENSE +202 -0
- package/NOTICE +7 -0
- package/README.md +22 -20
- package/dist/anchor-BhsfeHwL.js +1 -0
- package/dist/attach-D451Wj4h.js +21 -0
- package/dist/chat-ByOXN5k1.js +64 -0
- package/dist/claims-BfpRuIu-.js +1 -0
- package/dist/consent-BupCs23W.js +1 -0
- package/dist/contract.js +1 -1
- package/dist/feedback-DtMDnAam.js +1 -0
- package/dist/help-D_T0HiNa.js +106 -0
- package/dist/{hook-DGWypoEO.js → hook-BRnJ-lTk.js} +1 -1
- package/dist/index.js +6 -8
- package/dist/loader-k4pePzAw.js +127 -0
- package/dist/mask-audit-DtKNgOlT.js +5 -0
- package/dist/react.js +1 -1
- package/dist/resolve-7jVqhJhi.js +1 -0
- package/dist/script.js +1 -1
- package/dist/{signals-amjMQyOy.js → signals-eaZX2lNd.js} +1 -1
- package/dist/telemetry-DMGFJcw3.js +1 -0
- package/dist/{transport-B64CfIcF.js → transport-DokImbgl.js} +1 -1
- package/dist/types/chat/capture/attach.d.ts +2 -0
- package/dist/types/chat/shell/converse.d.ts +2 -0
- package/dist/types/chat/transport.d.ts +1 -1
- package/dist/types/claims.d.ts +37 -0
- package/dist/types/help/core/client.d.ts +3 -0
- package/dist/types/help/core/events.d.ts +1 -1
- package/dist/types/help/core/routing.d.ts +2 -0
- package/dist/types/loader.d.ts +3 -0
- package/dist/types/preview/mask-audit.d.ts +3 -1
- package/dist/types/telemetry/telemetry.d.ts +4 -0
- package/dist/types/types.d.ts +34 -0
- package/dist/types/widget/feedback.d.ts +7 -1
- package/dist/types/widget/upload.d.ts +3 -2
- package/dist/{upload-Fu2qvSJV.js → upload-DkAWrJhn.js} +6 -6
- package/dist/widget-CcAalO4B.js +118 -0
- package/package.json +4 -3
- package/LICENSE.md +0 -27
- package/dist/anchor-cPvFFTOS.js +0 -1
- package/dist/attach-DpioALxW.js +0 -21
- package/dist/chat-BgmB0rnW.js +0 -64
- package/dist/consent-DckCUvYR.js +0 -1
- package/dist/context-UnG6_X61.js +0 -17
- package/dist/feedback-CtH1a_kQ.js +0 -1
- package/dist/help-w0O5Qu-4.js +0 -105
- package/dist/index-CwG2LrhO.js +0 -20
- package/dist/loader-BZiIDD1D.js +0 -96
- package/dist/mask-audit-Du3NPoG_.js +0 -5
- package/dist/resolve-BfWByuTp.js +0 -1
- package/dist/telemetry-CyRJDaVs.js +0 -1
- package/dist/widget-B6mR1J3P.js +0 -118
package/AGENTS.md
CHANGED
|
@@ -12,7 +12,7 @@ The public types in this package (`dist/types`) follow them.
|
|
|
12
12
|
- `siteKey` (`pk_` + 32 hex, `SITE_KEY_PATTERN`) is **public** runtime config per site. It is not a secret.
|
|
13
13
|
- Direct mode is the default: the browser calls `https://app.journeeze.dev` with CORS for the
|
|
14
14
|
site's allowlisted origins. Set `apiHost` (script tag: `data-journeeze-api-host`) in every
|
|
15
|
-
environment except production: `https://
|
|
15
|
+
environment except production: `https://staging.journeeze.dev` for a staging site key,
|
|
16
16
|
`http://localhost:8080` for the local stack, or the host's own origin when it runs a same-origin
|
|
17
17
|
proxy (then `apiPath` for a sub-path). Keep it in the same runtime config as the site key. The
|
|
18
18
|
SDK never infers it from where the script was loaded. `http:` is accepted only for
|
|
@@ -20,7 +20,7 @@ The public types in this package (`dist/types`) follow them.
|
|
|
20
20
|
- CSP, if the host sends one: `script-src 'self' https://app.journeeze.dev` (+ `'wasm-unsafe-eval'`
|
|
21
21
|
only with signals), `connect-src 'self' https://app.journeeze.dev`, `img-src 'self' blob:
|
|
22
22
|
https://app.journeeze.dev`, `media-src 'self' https://app.journeeze.dev`, and pass your `nonce`.
|
|
23
|
-
Use `
|
|
23
|
+
Use `staging.journeeze.dev` for staging.
|
|
24
24
|
|
|
25
25
|
## Identity
|
|
26
26
|
- `userId` is optional. It must be `HMAC-SHA256(per-environment secret, internal user id)` computed
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.2.0 (2026-10-29)
|
|
4
|
+
|
|
5
|
+
First stable release after 0.1.0. Additive: existing 0.1.x integrations need no change.
|
|
6
|
+
|
|
7
|
+
- **Signed claims v2 (contract §15; released by owner decision 2026-10-29, journeeze-saas#298, Allumata review to follow):** opt-in; sites keep accepting v1 identities until their `min_claims_version` is raised. new `claims` option (the host server's signed token) and `getToken()` refresh callback. The SDK sends the token on feedback, screenshot uploads, help reads, intent routing and chat turns while it is well formed and more than 60 s from its `exp`, asks `getToken()` for a fresh one otherwise, and never reuses a token after `reset()`. Entitlement-gated guides are served only with a verified token, and help picks persona guides for the verified `profile.kind`. A token's life is measured from when the page saw it (`exp − iat`), so a wrong page clock does not matter; `getToken()` is called at most once per 15 s while the current token works; feedback and telemetry sends never wait for it. The loader only forgets the token on `reset()`; the checks live in the lazy chunks.
|
|
8
|
+
|
|
9
|
+
- **License:** the SDK is now open source under the Apache License 2.0 (owner decision 2026-10-18, #245). `LICENSE` and `NOTICE` replace the proprietary `LICENSE.md`; npm metadata reads `Apache-2.0`. Versions up to 0.1.0-rc.3 were published under the previous proprietary terms.
|
|
10
|
+
|
|
11
|
+
## 0.1.0 (2026-10-18)
|
|
12
|
+
|
|
13
|
+
Stable release published from commit 3df591d (no separate entry was recorded at the time).
|
|
14
|
+
|
|
15
|
+
## 0.1.0-rc.3 (2026-10-18)
|
|
4
16
|
|
|
5
17
|
- **Setup documentation:** the README is a self-contained setup guide: what the Journeeze team sends you, install with a pinned version, `apiHost` per environment, CSP, signed identity with a test vector, privacy and masking, help, feedback, signals, the Journeeze GitHub App and its permissions, a checklist and troubleshooting. Examples use `window.Journeeze` only after `DOMContentLoaded`. The license line matches `LICENSE.md`.
|
|
6
18
|
- **Help chat on the live `Converse` (HC8c):** each turn carries the reviewer token (when the host has one), and on consented turns the signed user id (`userId`, `userIdExp`, `userIdSig`) and the detector's over-masking counts (`overMasked`, counts per rule only). Closing the chat (✕ or Esc) ends a started conversation with a `cancel` turn; opening it again starts a new one.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Journeeze SDK (@journeeze/sdk)
|
|
2
|
+
Copyright 2026 Matt Cochran Products
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
Third-party components bundled into dist/ are licensed under their own terms; see
|
|
7
|
+
dist/THIRD_PARTY_LICENSES.txt.
|
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ the Journeeze team ([Before you start](#before-you-start)).
|
|
|
42
42
|
With your production site key:
|
|
43
43
|
|
|
44
44
|
```sh
|
|
45
|
-
npm install @journeeze/sdk@
|
|
45
|
+
npm install @journeeze/sdk@latest --save-exact
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
`rc` selects the current release candidate; `--save-exact` pins the resolved version. Commit your
|
|
@@ -67,7 +67,7 @@ document.querySelector("#send-feedback")?.addEventListener("click", () => {
|
|
|
67
67
|
});
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
For a staging site key, also set `apiHost: "https://
|
|
70
|
+
For a staging site key, also set `apiHost: "https://staging.journeeze.dev"`; see
|
|
71
71
|
[Environments](#environments-and-apihost). Mark customer content with `data-jz-mask` before testing.
|
|
72
72
|
|
|
73
73
|
1. Open your registered app origin and click **Send feedback**.
|
|
@@ -108,13 +108,12 @@ Pick one way. Both load the same code.
|
|
|
108
108
|
### npm (bundled apps)
|
|
109
109
|
|
|
110
110
|
```sh
|
|
111
|
-
npm install @journeeze/sdk@
|
|
111
|
+
npm install @journeeze/sdk@latest --save-exact
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
The command resolves `
|
|
115
|
-
`npm install @journeeze/sdk@<version> --save-exact`. Release candidates
|
|
116
|
-
tag;
|
|
117
|
-
an unqualified `npm install @journeeze/sdk` can select an older version than `rc`.
|
|
114
|
+
The command resolves `latest` (the newest stable release) and pins that exact version. To choose
|
|
115
|
+
a particular release, use `npm install @journeeze/sdk@<version> --save-exact`. Release candidates
|
|
116
|
+
(`-rc.N`) are on the `rc` tag; install them only when the Journeeze team asks you to test one.
|
|
118
117
|
|
|
119
118
|
**React:**
|
|
120
119
|
|
|
@@ -152,7 +151,7 @@ function HelpButton() {
|
|
|
152
151
|
```ts
|
|
153
152
|
import { createJourneeze } from "@journeeze/sdk";
|
|
154
153
|
|
|
155
|
-
const jz = createJourneeze({ siteKey: "pk_...", apiHost: "https://
|
|
154
|
+
const jz = createJourneeze({ siteKey: "pk_...", apiHost: "https://staging.journeeze.dev" });
|
|
156
155
|
document.querySelector("#help")?.addEventListener("click", () => jz.enableHelp());
|
|
157
156
|
```
|
|
158
157
|
|
|
@@ -197,7 +196,7 @@ refused, so set `apiHost` next to the site key in each environment's config:
|
|
|
197
196
|
| Environment | `apiHost` / `data-journeeze-api-host` |
|
|
198
197
|
|---|---|
|
|
199
198
|
| Production | leave it out |
|
|
200
|
-
| Staging | `https://
|
|
199
|
+
| Staging | `https://staging.journeeze.dev` |
|
|
201
200
|
| Local Journeeze stack | `http://localhost:8080` |
|
|
202
201
|
| Your own same-origin proxy | your origin, for example `https://www.example.com` |
|
|
203
202
|
|
|
@@ -208,7 +207,7 @@ proxy guide (gateway key, the paths to forward, reference Worker and server code
|
|
|
208
207
|
|
|
209
208
|
## Content Security Policy
|
|
210
209
|
|
|
211
|
-
If your site sends a CSP, add these. Use `https://
|
|
210
|
+
If your site sends a CSP, add these. Use `https://staging.journeeze.dev` on staging.
|
|
212
211
|
|
|
213
212
|
```
|
|
214
213
|
script-src 'self' https://app.journeeze.dev;
|
|
@@ -361,8 +360,10 @@ Each call uses a one-hour token limited to that repository. You can remove the A
|
|
|
361
360
|
(GitHub → Settings → Applications → Installed GitHub Apps). Journeeze then stops reading and
|
|
362
361
|
filing.
|
|
363
362
|
|
|
364
|
-
**
|
|
365
|
-
|
|
363
|
+
**Then connect it on the board.** On the Journeeze board, open **Onboarding** and click
|
|
364
|
+
**Connect GitHub**. Sign in with GitHub, pick the repository (only repositories where the App is
|
|
365
|
+
installed and you are an admin are listed) and its catalog folder (default `.jevitate/`). Only
|
|
366
|
+
project owners can connect a repository.
|
|
366
367
|
|
|
367
368
|
**Your journey catalog.** Journeeze reads the [Jevitate](https://jevitate.com) catalog in your repository's `.jevitate/`
|
|
368
369
|
folder (personas, jobs and journeys) on each push. Guides with screenshots and video are imported
|
|
@@ -370,9 +371,9 @@ from your approved journeys as drafts. A triager reviews each one on the board (
|
|
|
370
371
|
lightly edit the step text, and publishes it. Only published guides appear in help.
|
|
371
372
|
|
|
372
373
|
**Without the App: upload from CI.** Your CI can upload the catalog as a bundle instead:
|
|
373
|
-
`POST https://app.journeeze.dev/api/upload/v1/bundles` with `Authorization: Bearer jzu_…`.
|
|
374
|
-
|
|
375
|
-
|
|
374
|
+
`POST https://app.journeeze.dev/api/upload/v1/bundles` with `Authorization: Bearer jzu_…`. A
|
|
375
|
+
project owner creates the key on the board (**Settings → Upload keys**); it is shown once. Store it
|
|
376
|
+
as the CI secret `JOURNEEZE_UPLOAD_KEY`. Never put an upload key in a URL or a log.
|
|
376
377
|
|
|
377
378
|
## Setup checklist
|
|
378
379
|
|
|
@@ -384,7 +385,7 @@ for the bundle format and a CI example. Never put an upload key in a URL or a lo
|
|
|
384
385
|
- [ ] `data-tflow-id` on every element a guide points at; `journeyStep` set per route.
|
|
385
386
|
- [ ] Signed-in users: user id and signature made on your server and delivered `no-store`;
|
|
386
387
|
`reset()` on every logout path.
|
|
387
|
-
- [ ] Journeeze GitHub App installed on your repository, and the
|
|
388
|
+
- [ ] Journeeze GitHub App installed on your repository, and the repository connected on the board (Onboarding → Connect GitHub).
|
|
388
389
|
- [ ] Help switched on for the site on the board, audience chosen, guides published.
|
|
389
390
|
- [ ] One test feedback item sent from each site and seen on the board.
|
|
390
391
|
|
|
@@ -401,7 +402,7 @@ for the bundle format and a CI example. Never put an upload key in a URL or a lo
|
|
|
401
402
|
| Feedback is anonymous although `userId` is set | The signature is missing, wrong, expired, or made for another site key. |
|
|
402
403
|
| `userId` ignored with a console warning | It is not a 64-hex or 43-base64url hash (for example a raw UUID or an email). |
|
|
403
404
|
| `429` responses from an office or CI | Many users share one IP address. Use a proxy, or ask for a higher quota. |
|
|
404
|
-
| Issues are never filed | The Journeeze GitHub App is not installed on the repository, or the
|
|
405
|
+
| Issues are never filed | The Journeeze GitHub App is not installed on the repository, or the repository is not connected on the board (Onboarding shows its state). |
|
|
405
406
|
|
|
406
407
|
## Versions and license
|
|
407
408
|
|
|
@@ -409,6 +410,7 @@ Changes are listed in `CHANGELOG.md` in this package. Public types ship in `dist
|
|
|
409
410
|
`@journeeze/sdk/contract` exports `SITE_KEY_PATTERN` and `USER_ID_PATTERN` for your server's
|
|
410
411
|
tests.
|
|
411
412
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
413
|
+
Licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
|
414
|
+
(`LICENSE` and `NOTICE` in this package). You may read, modify and redistribute it under those
|
|
415
|
+
terms. Using the hosted Journeeze service is governed by your agreement for that service, not by
|
|
416
|
+
this license.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as f}from"./loader-k4pePzAw.js";const g=512,p=12;function b(t){const n=[];let o=t,e=false;for(let i=0;o&&i<p;i++){const r=o.hasAttribute("data-tflow-id")?f(o):void 0;if(r!==void 0&&o.getAttribute("data-tflow-id")===r){n.unshift(`[data-tflow-id="${r}"]`),e=true;break}const s=o.tagName.toLowerCase();if(s==="body"||s==="html"){n.unshift(s),e=true;break}const c=o,l=c.parentElement;let d=s;if(l){const u=Array.from(l.children).filter(m=>m.tagName===c.tagName);u.length>1&&(d+=`:nth-of-type(${u.indexOf(c)+1})`)}n.unshift(d),o=l}const a=n.join(" > ");return e&&a.length<=g?a:void 0}const h=t=>Number.isFinite(t)?Math.min(1,Math.max(0,t)):.5;function v(t,n,o){const e=t.getBoundingClientRect(),a={xRatio:h(e.width>0?(n-e.left)/e.width:.5),yRatio:h(e.height>0?(o-e.top)/e.height:.5)},i=f(t);i!==void 0&&(a.tflowId=i);const r=b(t);return r!==void 0&&(a.cssSelector=r),a}function A(t){return f(t)??t.tagName.toLowerCase()}function k(t){return t.closest("[data-jz-block]")!==null}function C(t){return t<768?"mobile":t<1024?"tablet":"desktop"}export{v as a,C as d,A as e,k as i};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import{a as K}from"./loader-k4pePzAw.js";import{i as q}from"./anchor-BhsfeHwL.js";import{a as V,p as G}from"./upload-DkAWrJhn.js";import{m as Se}from"./upload-DkAWrJhn.js";import{M as T,u as J}from"./chat-ByOXN5k1.js";const R=10,j=.02,z=.01,h=(e,n,t)=>Number.isFinite(e)?Math.min(t,Math.max(n,e)):n,p=e=>Math.round(e*1e4)/1e4;function Q(e,n,t){return{x:h(t.width>0?(e-t.left)/t.width:0,0,1),y:h(t.height>0?(n-t.top)/t.height:0,0,1)}}function $(e,n,t){const i=h(n.x,0,1),a=h(n.y,0,1),r=h(t.x,0,1),s=h(t.y,0,1);return e==="arrow"?{type:e,x:p(i),y:p(a),w:p(r-i),h:p(s-a)}:{type:e,x:p(Math.min(i,r)),y:p(Math.min(a,s)),w:p(Math.abs(r-i)),h:p(Math.abs(s-a))}}function Z(e){return Math.abs(e.w)<z&&Math.abs(e.h)<z}function ee(e){return e==="arrow"?{type:e,x:.35,y:.35,w:.15,h:.15}:{type:e,x:.35,y:.4,w:.3,h:.2}}function te(e,n,t,i){const a=e.type==="arrow";if(i){const c=a?h(e.w+n,-e.x,1-e.x):h(e.w+n,z,1-e.x),u=a?h(e.h+t,-e.y,1-e.y):h(e.h+t,z,1-e.y);return{...e,w:p(c),h:p(u)}}const r=h(e.x+n,Math.max(0,-e.w),Math.min(1,1-e.w)),s=h(e.y+t,Math.max(0,-e.h),Math.min(1,1-e.h));return{...e,x:p(r),y:p(s)}}function U(e,n,t,i,a){const r=Math.atan2(i-n,t-e),s=c=>`${p(t-a*Math.cos(r+c))},${p(i-a*Math.sin(r+c))}`;return`${p(t)},${p(i)} ${s(Math.PI/7)} ${s(-Math.PI/7)}`}function ne(e,n,t,i){e.strokeStyle=e.fillStyle="#B42318",e.lineWidth=Math.max(2,Math.round(Math.max(t,i)/160));for(const a of n)if(e.beginPath(),a.type==="box"?e.rect(a.x*t,a.y*i,a.w*t,a.h*i):a.type==="circle"?e.ellipse((a.x+a.w/2)*t,(a.y+a.h/2)*i,a.w/2*t,a.h/2*i,0,0,Math.PI*2):(e.moveTo(a.x*t,a.y*i),e.lineTo((a.x+a.w)*t,(a.y+a.h)*i)),e.stroke(),a.type==="arrow"){const r=U(a.x*t,a.y*i,(a.x+a.w)*t,(a.y+a.h)*i,e.lineWidth*4).split(" ").map(s=>s.split(",").map(Number));e.beginPath(),r.forEach(([s,c],u)=>u?e.lineTo(s,c):e.moveTo(s,c)),e.fill()}}const ae="http://www.w3.org/2000/svg",B=["box","circle","arrow"];function m(e,n={},...t){const i=document.createElement(e);for(const[a,r]of Object.entries(n))i.setAttribute(a,r);return i.append(...t),i}function M(e,n){const t=document.createElementNS(ae,e);for(const[i,a]of Object.entries(n))t.setAttribute(i,String(a));return t}function ie(e,n,t){const i={fill:"none",stroke:"#B42318","stroke-width":3,"vector-effect":"non-scaling-stroke"};if(e.type==="box")return M("rect",{x:e.x*n,y:e.y*t,width:e.w*n,height:e.h*t,...i});if(e.type==="circle")return M("ellipse",{cx:(e.x+e.w/2)*n,cy:(e.y+e.h/2)*t,rx:e.w/2*n,ry:e.h/2*t,...i});const[a,r,s,c]=[e.x*n,e.y*t,(e.x+e.w)*n,(e.y+e.h)*t],u=M("g",{});return u.append(M("line",{x1:a,y1:r,x2:s,y2:c,...i}),M("polygon",{points:U(a,r,s,c,Math.max(n,t)/50),fill:"#B42318"})),u}function oe(e,n,t,i){return new Promise(a=>{let r="box",s=[],c,u;const v=B.map(o=>{const d=m("button",{type:"button",class:"tool","aria-pressed":String(o===r)},i(`draw.${o}`));return d.addEventListener("click",()=>{r=o,v.forEach((g,b)=>g.setAttribute("aria-pressed",String(B[b]===o)))}),d}),l=(o,d,g)=>{const b=m("button",{type:"button",class:d},o);return b.addEventListener("click",g),b},w=l(i("draw.undo"),"tool",()=>A(s.slice(0,-1),i("draw.removed_last"))),y=l(i("draw.clear"),"tool",()=>A([],i("draw.cleared"))),N=l(i("cancel"),"btn",()=>P(void 0)),X=l(i("draw.done"),"btn pri",()=>P(s)),I=M("svg",{viewBox:`0 0 ${t.w} ${t.h}`,preserveAspectRatio:"none","aria-hidden":"true"}),H=m("img",{src:n,alt:i("draw.image"),draggable:"false"}),W=m("span",{id:"jzd-k",class:"sr"},i("draw.keys")),f=m("div",{class:"stage",tabindex:"0",role:"group","aria-label":i("draw.stage"),"aria-describedby":"jzd-k"},H,I,W),L=m("p",{class:"msg",role:"status"}),E=m("div",{class:"jzd",role:"dialog","aria-modal":"true","aria-labelledby":"jzd-t","aria-describedby":"jzd-h"},m("header",{},m("h2",{id:"jzd-t"},i("draw.title")),m("p",{id:"jzd-h"},i("draw.hint"))),m("div",{class:"bar",role:"toolbar","aria-label":i("draw.tools")},...v,m("span",{class:"sep","aria-hidden":"true"}),w,y,m("span",{class:"end"},N,X)),m("div",{class:"wrap"},f),L);function k(){I.replaceChildren(...[...s,...u?[u]:[]].map(o=>ie(o,t.w,t.h))),w.disabled=y.disabled=s.length===0}function A(o,d){s=o,L.textContent=d,k()}function O(o){if(s.length>=R){L.textContent=i("draw.shape_limit",{max:R});return}A([...s,o],i(`draw.added.${o.type}`,{n:s.length+1,max:R}))}function S(){const o=f.parentElement,d=getComputedStyle(o),g=Math.max(1,o.clientWidth-parseFloat(d.paddingLeft||"0")-parseFloat(d.paddingRight||"0")),b=Math.max(1,o.clientHeight-parseFloat(d.paddingTop||"0")-parseFloat(d.paddingBottom||"0")),C=Math.min(g/t.w,b/t.h);f.style.width=`${Math.floor(t.w*C)}px`,f.style.height=`${Math.floor(t.h*C)}px`}const _=o=>Q(o.clientX,o.clientY,f.getBoundingClientRect());f.addEventListener("pointerdown",o=>{o.button===0&&(o.preventDefault(),f.setPointerCapture?.(o.pointerId),c=_(o))}),f.addEventListener("pointermove",o=>{c&&(u=$(r,c,_(o)),k())});const Y=o=>{if(!c)return;const d=$(r,c,_(o));c=u=void 0,Z(d)?k():O(d)};f.addEventListener("pointerup",Y),f.addEventListener("pointercancel",()=>{c=u=void 0,k()}),f.addEventListener("keydown",o=>{const d={ArrowLeft:[-j,0],ArrowRight:[j,0],ArrowUp:[0,-j],ArrowDown:[0,j]};if(o.key==="Enter"||o.key===" ")o.preventDefault(),O(ee(r));else if(d[o.key]&&s.length>0){o.preventDefault();const[g,b]=d[o.key];s=[...s.slice(0,-1),te(s[s.length-1],g,b,o.shiftKey)],k()}}),E.addEventListener("keydown",o=>{if(o.stopPropagation(),o.key==="Escape")o.preventDefault(),P(void 0);else if(o.key==="Tab"){const d=[...E.querySelectorAll("button:not([disabled]), [tabindex='0']")],g=d.indexOf(e.activeElement);(o.shiftKey?g<=0:g===d.length-1)&&(o.preventDefault(),d[o.shiftKey?d.length-1:0]?.focus())}}),window.addEventListener("resize",S);function P(o){window.removeEventListener("resize",S),E.remove(),a(o)}e.append(E),k(),S(),v[0].focus()})}const re=`
|
|
2
|
+
.jzd{position:fixed;inset:0;z-index:2147483647;display:flex;flex-direction:column;background:var(--c);color:var(--i)}
|
|
3
|
+
.jzd header{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px;padding:12px 16px;border-bottom:1px solid var(--l);background:var(--s)}
|
|
4
|
+
.jzd h2{margin:0;font-size:14px;font-weight:600}
|
|
5
|
+
.jzd header p{margin:0;font-size:12px;color:var(--m)}
|
|
6
|
+
.jzd .bar{display:flex;flex-wrap:wrap;align-items:center;gap:6px;padding:8px 16px;border-bottom:1px solid var(--l);background:var(--s)}
|
|
7
|
+
.jzd .bar .sep{width:1px;height:28px;background:var(--l);margin:0 4px}
|
|
8
|
+
.jzd .bar .end{margin-left:auto;display:flex;gap:6px}
|
|
9
|
+
.jzd .tool{min-width:44px;min-height:44px;padding:0 12px;border:1px solid var(--l);border-radius:6px;background:var(--s)}
|
|
10
|
+
.jzd .tool[aria-pressed=true]{background:var(--as);border-color:var(--a);color:var(--a);font-weight:600}
|
|
11
|
+
.jzd .wrap{flex:1;min-height:0;display:grid;place-items:center;padding:16px}
|
|
12
|
+
.jzd .stage{position:relative;border:1px solid var(--l);border-radius:6px;overflow:hidden;background:var(--r);touch-action:none;cursor:crosshair;user-select:none;-webkit-user-select:none}
|
|
13
|
+
.jzd .stage img,.jzd .stage svg{position:absolute;inset:0;width:100%;height:100%;display:block}
|
|
14
|
+
.jzd .stage svg{overflow:visible}
|
|
15
|
+
.jzd .stage *{pointer-events:none}
|
|
16
|
+
.jzd .msg{min-height:20px;margin:0;padding:0 16px 8px;font-size:12px;color:var(--m)}
|
|
17
|
+
.pick{position:fixed;inset:0;z-index:2147483647;cursor:crosshair;touch-action:none}
|
|
18
|
+
.pick .hl{position:fixed;border:2px solid var(--a);border-radius:4px;background:var(--as);pointer-events:none}
|
|
19
|
+
.pick .hint{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);display:flex;align-items:center;gap:8px;max-width:calc(100vw - 32px);padding:4px 4px 4px 16px;border:1px solid var(--l);border-radius:10px;background:var(--s);box-shadow:var(--sh);font-size:13px}
|
|
20
|
+
@media (max-width:640px){.jzd .bar .end{margin-left:0;width:100%}.jzd .bar .end .btn{flex:1}.jzd .wrap{padding:8px}}
|
|
21
|
+
`,D=["image/png","image/jpeg","image/webp","image/gif"],se=10*1024*1024,ce=2*1024*1024,de=1600,le="[data-journeeze], [data-journeeze-chat]",x=(e,n)=>e.session.note(e.session.t(n,{max:T}));async function ze(e,n){return pe(n),e==="point_at_it"?ge(n):n.options.reviewerToken||n.options.userId||n.options.claims||n.options.getToken?n.session.attachments.length>=T?x(n,"note.attachment_limit"):e==="show_us_where"?he(n):xe(n):x(n,"note.signed_out")}function pe(e){if(e.root.querySelector("style[data-jz-capture]"))return;const n=document.createElement("style");n.setAttribute("data-jz-capture",""),n.textContent=re,e.options.nonce&&(n.nonce=e.options.nonce),e.root.append(n)}async function ue(e){const n=await e.config(),t=Array.isArray(n.maskSelectors)?n.maskSelectors:[],{maskSelectors:i,maskAllText:a}=e.options;return{...i?{maskSelectors:i}:{},...t.length?{configMaskSelectors:t}:{},...a?{maskAllText:a}:{}}}async function me(e){try{const n=await V(document.body,await ue(e));if(n.blob)for(const[t,i]of Object.entries(n.detectorCounts))i&&e.session.overMask.set(t,(e.session.overMask.get(t)??0)+i);return n.blob}catch{return}}async function he(e){const n=e.suspend(),t=await me(e);if(!t)return n(),x(e,"note.masking_failed");const i={w:Math.max(1,window.innerWidth),h:Math.max(1,window.innerHeight)},a=URL.createObjectURL(t),r=await oe(e.root,a,i,e.session.t);URL.revokeObjectURL(a),n(),r&&await F(e,t,i,r,"attachment.screenshot")}async function F(e,n,t,i,a){const r=await fe(n,t,i);e.session.addAttachment({id:J(),thumbnail:r,label:e.session.t(a,{n:e.session.attachments.length+1}),...i.length?{shapes:i}:{},upload:async()=>G(e.endpoint,e.options,n,void 0,await e.claims?.()),release:()=>URL.revokeObjectURL(r)})||(URL.revokeObjectURL(r),x(e,"note.attachment_limit"))}async function fe(e,n,t){try{const i=await createImageBitmap(e),a=document.createElement("canvas");a.width=256,a.height=Math.max(1,Math.round(256*n.h/n.w));const r=a.getContext("2d");r.drawImage(i,0,0,a.width,a.height),ne(r,t,a.width,a.height);const s=await new Promise(c=>a.toBlob(c,"image/webp",.8));if(s)return URL.createObjectURL(s)}catch{}return URL.createObjectURL(e)}async function ge(e){const n=e.suspend(),t=await be(e.root,e.session.t);if(n(),!t)return;const i=q(t)?void 0:K(t);i?e.session.setAnchor({tflowId:i}):x(e,"note.no_name")}function we(e,n){return document.elementsFromPoint(e,n).find(t=>!t.closest(le)&&t!==document.documentElement)}function be(e,n){return new Promise(t=>{const i=document.createElement("div");i.className="hl",i.hidden=true;const a=document.createElement("button");a.type="button",a.className="btn",a.textContent=n("cancel");const r=document.createElement("div");r.className="hint",r.setAttribute("role","dialog"),r.setAttribute("aria-label",n("point.label")),r.append(n("point.hint"),a);const s=document.createElement("div");s.className="pick",s.append(i,r);const c=l=>{const w=we(l.clientX,l.clientY);return w?.closest("[data-tflow-id]")??w};s.addEventListener("pointermove",l=>{const w=c(l);if(i.hidden=!w,!w)return;const y=w.getBoundingClientRect();Object.assign(i.style,{left:`${y.left}px`,top:`${y.top}px`,width:`${y.width}px`,height:`${y.height}px`})}),s.addEventListener("pointerup",l=>{r.contains(l.target)||v(c(l))}),a.addEventListener("click",()=>v(void 0));const u=l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),v(void 0))};document.addEventListener("keydown",u,true);function v(l){document.removeEventListener("keydown",u,true),s.remove(),t(l)}e.append(s),a.focus()})}function xe(e){return new Promise(n=>{const t=document.createElement("input");t.type="file",t.accept=D.join(","),t.hidden=true,e.root.append(t),t.addEventListener("change",()=>{const i=t.files?.[0];t.remove(),i?ve(e,i).then(n):n()}),t.addEventListener("cancel",()=>{t.remove(),n()}),t.click()})}async function ve(e,n){if(!D.includes(n.type)||n.size>se)return x(e,"note.file_type");if(e.session.attachments.length>=T)return x(e,"note.attachment_limit");const t=await ye(n).catch(()=>{});if(!t)return x(e,"note.file_read");await F(e,t.blob,t.size,[],"attachment.image")}async function ye(e){const n=await createImageBitmap(e,{imageOrientation:"from-image"});let t=Math.min(1,de/Math.max(n.width,n.height));for(const i of[.85,.7,.5]){const a=document.createElement("canvas");a.width=Math.max(1,Math.round(n.width*t)),a.height=Math.max(1,Math.round(n.height*t)),a.getContext("2d").drawImage(n,0,0,a.width,a.height);const r=await new Promise(s=>a.toBlob(s,"image/webp",i));if(!r||r.type!=="image/webp"&&r.type!=="image/png")return;if(r.size<=ce)return{blob:r,size:{w:a.width,h:a.height}};t*=.75}}export{D as IMAGE_TYPES,se as MAX_FILE_BYTES,ve as addFile,ue as maskOptions,me as maskedCapture,Se as maskedSnapshotSvg,we as pageElementAt,be as pick,ze as plusItem,ye as reencode};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var X=Object.defineProperty;var Y=(i,e,t)=>e in i?X(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t;var c=(i,e,t)=>Y(i,typeof e!="symbol"?e+"":e,t);import{c as q,C as Q,j as Z,d as ee,i as te,f as H,h as ne,s as ie,e as re}from"./consent-BupCs23W.js";const ae="journeeze.turn/v1";class se extends Error{constructor(t,n){super(t);c(this,"kind");c(this,"status");this.kind=t,this.status=n}}function L(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const i=crypto.getRandomValues(new Uint8Array(16));i[6]=i[6]&15|64,i[8]=i[8]&63|128;const e=[...i].map(t=>t.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}function oe(i){const e=i instanceof Q?i.status:0,t=e===429?"busy":e===400?"invalid":"unavailable";return new se(t,e)}function de(i,e=(...t)=>fetch(...t)){return{turn:t=>q(i,"Converse",t,e).then(n=>({...n,messages:n.messages??[],actions:n.actions??[],requiresConsent:!!n.requiresConsent}),n=>{throw oe(n)})}}function le(i,e,t,n){const r=de(i,t);return{turn:async d=>{const h=await n?.();return r.turn({...d,...e.reviewerToken&&{reviewerToken:e.reviewerToken},...d.consentGiven&&e.userId&&{userId:e.userId,...Z(e)},...h&&{claims:h}})}}}const ce="Help";function pe(i){return(e,t)=>(i?.["widget.ui."+e]??"").replace(/\{(\w+)\}/g,(n,r)=>String(t?.[r]??""))}function he(i,e){const t=e.toLowerCase().split(/\s+/).filter(Boolean);return i.filter(n=>t.every(r=>n.title.toLowerCase().includes(r)))}function ue(i){return typeof i.steps=="number"&&i.steps>0?i.steps:void 0}function fe(i){return/Edg\//.test(i)?"Edge":/Firefox\//.test(i)?"Firefox":/Chrome\/|CriOS\//.test(i)?"Chrome":/Safari\//.test(i)?"Safari":"Other"}function be(i,e,t){const n=[],r=(d,h,o=true)=>{h&&!e.has(d)&&n.push({key:d,label:h,removable:o})};return r("page",i.pagePath&&t("context.page",{value:i.pagePath})),r("job",i.job,false),r("step",i.step!==void 0&&t("context.step",{step:i.step}),false),r("persona",i.persona&&t("context.persona",{value:i.persona})),r("browser",i.browser),r("device",i.device&&(i.viewport?`${i.device} · ${i.viewport.w}×${i.viewport.h}`:i.device)),r("build",i.build&&t("context.build",{value:i.build})),n}const me=["page","persona","browser","device","viewport","build"];function ve(i,e){const t=new Set(e);t.has("device")&&t.add("viewport");const n={pagePath:t.has("page")?"":i.pagePath};i.persona&&!t.has("persona")&&(n.persona=i.persona),i.browser&&!t.has("browser")&&(n.browser=i.browser),i.device&&!t.has("device")&&(n.device=i.device),i.viewport&&!t.has("viewport")&&(n.viewport=i.viewport),i.build&&!t.has("build")&&(n.build=i.build);const r=me.filter(d=>t.has(d));return r.length>0&&(n.removed=r),n}const ge=5,xe="clarify_tap_only";class D{constructor(e){c(this,"deps");c(this,"conversationId",L());c(this,"entries",[]);c(this,"state","choose_job");c(this,"actions",[]);c(this,"requiresConsent",false);c(this,"pending",false);c(this,"error");c(this,"tapOnly",false);c(this,"consentAsked",false);c(this,"filed");c(this,"attachments",[]);c(this,"anchor");c(this,"removed",new Set);c(this,"team",{});c(this,"job");c(this,"step",0);c(this,"last");c(this,"ended",false);c(this,"opening",{chips:[]});c(this,"overMask",new Map);c(this,"listeners",new Set);c(this,"consent");c(this,"t");this.deps=e,this.consent=e.hasConsent(),this.t=e.t}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(){for(const e of this.listeners)e()}start(e){this.opening={chips:e},this.entries=[{kind:"assistant",copyId:"ask_job",text:this.t("greeting")}],this.actions=[...e,{type:"other_need",label:this.t("other_need")}],this.emit()}close(){if(this.ended||(this.ended=true,!this.last))return;const e=this.conversationId,t={kind:"action",action:"cancel"};this.send({turnId:L(),input:t}).then(n=>{e===this.conversationId&&(this.apply(t,n),this.emit())},()=>{})}reopen(){if(!this.ended)return;for(const t of this.attachments)t.release?.();const{chips:e}=this.opening;Object.assign(this,new D(this.deps),{listeners:this.listeners,overMask:this.overMask}),this.start(e)}offers(e){return this.actions.some(t=>t.type===e)}label(e){return this.actions.find(t=>t.type===e)?.label??""}chips(){return this.actions.filter(e=>e.type==="chip")}plusItems(){for(const e of this.actions)if(e.type==="plus_menu")return e.menu??e.items.map(t=>({id:t,label:""}));return[]}needsConsent(){return!this.consent&&(this.requiresConsent||this.offers("consent"))}allow(){this.deps.giveConsent(),this.consent=true,this.consentAsked=false,this.emit()}contextChips(){return be(this.facts(),this.removed,this.t)}removeContext(e){this.removed.add(e),this.emit()}setTeam(e){this.team={...this.team,...e}}teamOnWire(){const e={};return this.team.verdict&&(e.verdict=this.team.verdict),this.team.severity&&(e.severity=this.team.severity),e}addAttachment(e){const t=this.attachments.filter(n=>n.id!==e.id);return t.length>=ge?false:(this.attachments=[...t,e],this.emit(),true)}removeAttachment(e){this.attachments.find(t=>t.id===e)?.release?.(),this.attachments=this.attachments.filter(t=>t.id!==e),this.emit()}setAnchor(e){this.anchor=e,this.emit()}note(e){this.entries=[...this.entries,{kind:"note",text:e}],this.emit()}async uploadPending(){if(!this.consent)return;const e=this.attachments.filter(r=>!r.screenshotId&&r.upload),t=await Promise.all(e.map(r=>r.upload().catch(()=>{})));let n=false;e.forEach((r,d)=>{const h=t[d];h?this.attachments=this.attachments.map(o=>o===r?{...r,screenshotId:h}:o):(n=true,r.release?.(),this.attachments=this.attachments.filter(o=>o!==r))}),n&&(this.entries=[...this.entries,{kind:"note",text:this.t("note.upload_failed")}])}draft(){if(!this.consent)return;const e=this.attachments.flatMap(n=>n.screenshotId?[{screenshotId:n.screenshotId,...n.shapes?.length?{shapes:n.shapes}:{}}]:[]),t={};return e.length>0&&(t.attachments=e),this.anchor&&(t.anchor=this.anchor.tflowId),t.attachments||t.anchor?t:void 0}pickJob(e){this.job={id:e.jobId,title:e.title,of:ue(e)},this.run({kind:"action",action:"pick_job",jobId:e.jobId},e.title)}other(){this.run({kind:"action",action:"other_need"},this.label("other_need"))}next(){this.job&&this.run({kind:"action",action:"guide_next",jobId:this.job.id,step:this.step})}back(){this.state==="guide_step"&&this.job?this.run({kind:"action",action:"guide_back",jobId:this.job.id,step:this.step}):this.run({kind:"action",action:"guide_back"})}didntWork(){this.run({kind:"action",action:"didnt_work"},this.label("didnt_work"))}talk(){this.run({kind:"action",action:"talk_to_assistant"},this.label("talk_to_assistant"))}reportProblem(){this.run({kind:"action",action:"report_problem"},this.t("report_problem"))}sendText(e){const t=e.trim().slice(0,2e3);return!t||this.tapOnly||this.pending?false:this.needsConsent()?this.askConsent():(this.run({kind:"text",text:t},t),true)}sendReport(){return this.needsConsent()?this.askConsent():(this.run({kind:"action",action:"send"},this.label("send")),true)}retry(){this.last&&!this.pending&&this.exec(this.last)}askConsent(){return this.consentAsked=true,this.emit(),false}facts(){const e=this.deps.facts();return this.job?{...e,job:this.job.title,...this.step>0?{step:this.step}:{}}:e}run(e,t){this.pending||(t&&(this.entries=[...this.entries,{kind:"user",text:t}]),this.exec(this.last={turnId:L(),input:e}))}exec(e){this.pending=true,this.error=void 0,this.emit();const t=this.conversationId;this.uploadPending().then(()=>this.send(e)).then(n=>{t===this.conversationId&&this.apply(e.input,n)},n=>{t===this.conversationId&&(this.error=n.kind??"unavailable",this.error==="unavailable"&&(this.tapOnly=true))}).finally(()=>{this.pending=false,this.emit()})}send(e){const t=this.draft(),n=this.consent?[...this.overMask].map(([r,d])=>({rule:r,count:d})):[];return this.deps.transport.turn({siteKey:this.deps.siteKey,conversationId:this.conversationId,turnId:e.turnId,consentGiven:this.consent,context:ve(this.facts(),this.removed),schema:ae,payload:{input:e.input,...t?{draft:t}:{},...this.deps.reviewer&&(this.team.verdict||this.team.severity)?{team:this.teamOnWire()}:{}},...n.length?{overMasked:n}:{}}).then(r=>(n.length&&this.overMask.clear(),r))}apply(e,t){const n=this.state,r=e.kind==="action"?e.action:void 0;t.state==="guide_step"&&(r==="pick_job"?this.step=1:r==="guide_next"?this.step+=1:r==="guide_back"&&(this.step=Math.max(1,this.step-1)));const d=this.entries.map(o=>o.kind==="card"&&o.live?{...o,live:false}:o);let h;for(const o of t.messages)d.push({kind:"assistant",copyId:o.copyId,text:o.text}),o.card&&(o.card.step&&(this.step=o.card.step),this.job&&o.card.of&&(this.job.of=o.card.of),h={kind:"card",job:this.job?.title??"",step:this.step,of:o.card.of??this.job?.of,title:o.card.title,instruction:o.card.instruction,live:true});if(t.state==="guide_step"&&this.job&&d.push(h??{kind:"card",job:this.job.title,step:this.step,of:this.job.of,live:true}),t.state==="unmet_need"&&n!=="unmet_need"&&d.push({kind:"note",text:this.t("note.unmet")}),this.entries=d,this.tapOnly=t.messages.some(o=>o.copyId===xe),this.actions=t.actions,this.requiresConsent=t.requiresConsent,this.state=t.state,this.filed=t.filed?t.filed.kind??"problem":void 0,t.filed){for(const o of this.attachments)o.release?.();this.attachments=[],this.anchor=void 0,this.removed.clear(),this.team={}}["guide_step","didnt_work","gather","confirm_send"].includes(t.state)||(this.job=void 0,this.step=0)}}const ke=`
|
|
2
|
+
:host{all:initial;--c:#F7F7F5;--s:#FFF;--r:#F0F0EC;--i:#1D2024;--m:#5D636B;--f:#6C727B;--l:rgb(29 32 36/12%);--a:#3D63C9;--ai:#FFF;--as:rgb(61 99 201/10%);--sh:0 1px 3px rgb(0 0 0/12%),0 4px 12px rgb(0 0 0/8%);
|
|
3
|
+
font:400 13px/1.45 Inter,system-ui,-apple-system,"Segoe UI",sans-serif;color:var(--i);-webkit-font-smoothing:antialiased}
|
|
4
|
+
@media (prefers-color-scheme:dark){:host{--c:#111316;--s:#181B1F;--r:#20242A;--i:#E8EAED;--m:#A3A9B2;--f:#8A919B;--l:rgb(232 234 237/12%);--a:#7F9CF0;--ai:#111316;--as:rgb(127 156 240/14%)}}
|
|
5
|
+
*,*::before,*::after{box-sizing:border-box}
|
|
6
|
+
button,input,select{font:inherit;color:inherit}
|
|
7
|
+
button{cursor:pointer}
|
|
8
|
+
button:disabled,input:disabled{cursor:not-allowed;opacity:.55}
|
|
9
|
+
:focus-visible{outline:2px solid var(--a);outline-offset:2px}
|
|
10
|
+
[hidden]{display:none!important}
|
|
11
|
+
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
|
|
12
|
+
.launcher{position:fixed;right:24px;bottom:24px;z-index:2147483646;width:56px;height:56px;border-radius:999px;border:0;background:var(--a);color:var(--ai);font-size:24px;font-weight:600;box-shadow:var(--sh)}
|
|
13
|
+
.panel{position:fixed;right:24px;bottom:92px;z-index:2147483646;width:min(360px,calc(100vw - 48px));height:min(600px,calc(100vh - 116px));display:flex;flex-direction:column;background:var(--s);border:1px solid var(--l);border-radius:10px;box-shadow:var(--sh);overflow:hidden}
|
|
14
|
+
.head{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:8px 8px 8px 16px;border-bottom:1px solid var(--l);background:var(--c)}
|
|
15
|
+
.head h2{margin:0;font-size:13px;font-weight:600}
|
|
16
|
+
.head p{margin:0;font-size:12px;color:var(--f)}
|
|
17
|
+
.x{width:44px;height:44px;border:0;border-radius:6px;background:transparent;color:var(--m);font-size:20px}
|
|
18
|
+
.log{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:12px}
|
|
19
|
+
.msg{max-width:85%;padding:8px 12px;border:1px solid var(--l);border-radius:12px;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
20
|
+
.as{align-self:flex-start;background:var(--s);border-bottom-left-radius:2px}
|
|
21
|
+
.us{align-self:flex-end;background:var(--as);border-bottom-right-radius:2px}
|
|
22
|
+
.note{align-self:flex-start;margin:0;font-size:12px;color:var(--m)}
|
|
23
|
+
.card{align-self:flex-start;width:90%;padding:12px;border:1px solid var(--l);border-radius:10px;background:var(--c)}
|
|
24
|
+
.card h3{margin:0 0 4px;font-size:12px;font-weight:600;color:var(--a)}
|
|
25
|
+
.card p{margin:0 0 8px;color:var(--m)}
|
|
26
|
+
.row{display:flex;gap:8px;flex-wrap:wrap}
|
|
27
|
+
.btn{min-height:44px;padding:0 16px;border:1px solid var(--l);border-radius:6px;background:var(--s)}
|
|
28
|
+
.pri{background:var(--a);border-color:var(--a);color:var(--ai);font-weight:600}
|
|
29
|
+
.link{min-height:44px;padding:0 4px;border:0;background:none;color:var(--a);text-decoration:underline}
|
|
30
|
+
.foot{border-top:1px solid var(--l);padding:12px;display:flex;flex-direction:column;gap:8px;background:var(--s)}
|
|
31
|
+
.dyn{display:flex;flex-direction:column;gap:8px}.dyn:empty{display:none}
|
|
32
|
+
.chips{display:flex;flex-wrap:wrap;gap:6px}
|
|
33
|
+
.chip{min-height:44px;padding:0 12px;border:1px solid var(--l);border-radius:999px;background:var(--s);color:var(--m)}
|
|
34
|
+
.chip.job{border-color:var(--a);color:var(--a)}
|
|
35
|
+
.err{margin:0;padding:8px;border-radius:6px;background:var(--r);color:var(--i)}
|
|
36
|
+
.consent{margin:0;font-size:12px;color:var(--m)}
|
|
37
|
+
.consent.ask{color:var(--i);font-weight:600}
|
|
38
|
+
details{font-size:12px;color:var(--m)}
|
|
39
|
+
summary{cursor:pointer;min-height:24px}
|
|
40
|
+
.ctx{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px;padding:0;list-style:none}
|
|
41
|
+
.ctx li{display:flex;align-items:center;gap:2px;padding-left:8px;border:1px solid var(--l);border-radius:6px;background:var(--r);color:var(--i)}
|
|
42
|
+
.ctx li.fixed{padding-right:8px;min-height:32px}
|
|
43
|
+
.ctx button,.att button{width:32px;height:32px;border:0;background:none;color:var(--m)}
|
|
44
|
+
.team{display:flex;gap:8px;margin-top:6px}
|
|
45
|
+
.team label{display:flex;flex-direction:column;gap:2px;color:var(--i)}
|
|
46
|
+
.team select{min-height:32px;border:1px solid var(--l);border-radius:6px;background:var(--s)}
|
|
47
|
+
.atts{display:flex;flex-wrap:wrap;gap:8px;margin:0;padding:0;list-style:none}
|
|
48
|
+
.att{position:relative;width:64px;height:48px;border:1px solid var(--l);border-radius:6px;overflow:hidden;background:var(--r)}
|
|
49
|
+
.att img{width:100%;height:100%;object-fit:cover}
|
|
50
|
+
.pt{display:flex;align-items:center;gap:2px;padding-left:8px;border:1px solid var(--l);border-radius:6px;background:var(--r);font-size:12px;max-width:100%;overflow-wrap:anywhere}
|
|
51
|
+
.pt button{width:32px;height:32px;border:0;background:none;color:var(--m)}
|
|
52
|
+
.att button{position:absolute;top:0;right:0;background:var(--i);color:var(--s);border-radius:0 0 0 6px}
|
|
53
|
+
.comp{position:relative;display:flex;gap:6px;align-items:center}
|
|
54
|
+
.comp input{flex:1;min-width:0;min-height:44px;padding:0 12px;border:1px solid var(--l);border-radius:6px;background:var(--c)}
|
|
55
|
+
.ico{width:44px;height:44px;flex:none;border:1px solid var(--l);border-radius:6px;background:var(--s);font-size:18px}
|
|
56
|
+
.send{background:var(--a);border-color:var(--a);color:var(--ai)}
|
|
57
|
+
.menu{position:absolute;left:0;right:0;bottom:52px;z-index:1;padding:4px;margin:0;list-style:none;background:var(--s);border:1px solid var(--l);border-radius:10px;box-shadow:var(--sh)}
|
|
58
|
+
.menu button{display:block;width:100%;min-height:44px;padding:4px 12px;border:0;border-radius:6px;background:none;text-align:left}
|
|
59
|
+
.menu button:hover,.menu button:focus-visible{background:var(--c)}
|
|
60
|
+
.menu small{display:block;color:var(--f)}
|
|
61
|
+
.dots{align-self:flex-start;color:var(--f)}
|
|
62
|
+
@media (max-width:640px){.panel{inset:0;width:auto;height:auto;border-radius:0;border:0}.launcher[aria-expanded=true]{display:none}}
|
|
63
|
+
@media (prefers-reduced-motion:reduce){*{transition-duration:1ms!important}}
|
|
64
|
+
`,we=["unreviewed","polished","needs_polish","broken"],ye=["low","medium","high","critical"],_e=["didnt_work","gather","confirm_send","unmet_need"];function s(i,e={},...t){const n=document.createElement(i);for(const[r,d]of Object.entries(e))n.setAttribute(r,d);for(const r of t)r&&n.append(r);return n}function x(i,e,t,n={}){const r=s("button",{type:"button",class:e,...n},i);return r.addEventListener("click",t),r}function Ce(i,e,t){const n=e.t,r=s("button",{type:"button",class:"launcher","aria-label":n("launcher")||ce,"aria-expanded":"false","aria-controls":"jz-chat"},"?"),d=s("div",{class:"log",role:"log","aria-live":"polite","aria-label":n("conversation")}),h=s("div",{class:"dyn"});s("div");const o=s("input",{id:"jz-in",type:"text",autocomplete:"off",maxlength:"2000","aria-describedby":"jz-hint"}),S=s("span",{id:"jz-hint",class:"sr"}),k=s("button",{type:"button",class:"ico","aria-label":n("add_to_message"),"aria-haspopup":"menu","aria-expanded":"false","aria-controls":"jz-menu"},"+"),g=s("ul",{id:"jz-menu",class:"menu",role:"menu","aria-label":n("add_to_message")}),O=s("button",{type:"submit",class:"ico send","aria-label":n("send")},"➤"),C=s("form",{class:"comp"},g,k,s("label",{for:"jz-in",class:"sr"},n("message")),o,S,O),v=s("section",{id:"jz-chat",class:"panel",role:"dialog","aria-modal":"false","aria-labelledby":"jz-title"},s("header",{class:"head"},s("div",{},s("h2",{id:"jz-title"},n("title")),s("p",{},n("subtitle"))),x("✕","x",()=>A(),{"aria-label":n("close")})),d,s("div",{class:"foot"},h,C));v.hidden=true,g.hidden=true,i.append(r,v);let I=[],f=[];const T={ctx:false,team:false};r.addEventListener("click",()=>v.hidden?F():A()),o.addEventListener("input",()=>R()),C.addEventListener("submit",a=>{a.preventDefault(),e.sendText(o.value)&&(o.value="")}),k.addEventListener("click",()=>g.hidden?$():w(true)),g.addEventListener("keydown",a=>{const l=[...g.querySelectorAll("button")],b=l.indexOf(i.activeElement);a.key==="ArrowDown"||a.key==="ArrowUp"?(a.preventDefault(),l[(b+(a.key==="ArrowDown"?1:l.length-1))%l.length]?.focus()):a.key==="Tab"&&w(false)}),v.addEventListener("keydown",a=>{a.key==="Escape"&&(a.stopPropagation(),g.hidden?A():w(true))});function $(){g.replaceChildren(...e.plusItems().map(a=>{const l=s("button",{type:"button",role:"menuitem"},a.label,a.hint&&s("small",{},a.hint));return l.addEventListener("click",()=>{w(true),t.onPlusItem(a.id)}),s("li",{role:"none"},l)})),g.hidden=false,k.setAttribute("aria-expanded","true"),g.querySelector("button")?.focus()}function w(a){g.hidden=true,k.setAttribute("aria-expanded","false"),a&&k.focus()}function F(){e.reopen(),v.hidden=false,r.setAttribute("aria-expanded","true"),P(),(o.disabled?h.querySelector("button"):o)?.focus()}function A(){w(false),e.close(),v.hidden=true,r.setAttribute("aria-expanded","false"),r.focus()}function z(a){if(a.kind==="assistant")return s("div",{class:"msg as"},s("span",{class:"sr"},`${n("speaker.assistant")} `),a.text);if(a.kind==="user")return s("div",{class:"msg us"},s("span",{class:"sr"},`${n("speaker.you")} `),a.text);if(a.kind==="note")return s("p",{class:"note"},a.text);const l=`${a.job} · ${n(a.of?"card.step_of":"card.step",{step:a.step,of:a.of??""})}`,b=s("div",{class:"card",role:"group","aria-label":l},s("h3",{},l),a.title&&s("p",{},s("strong",{},a.title)),a.instruction&&s("p",{},a.instruction));if(a.live){const p=e.pending,j=x(e.label("guide_back"),"btn",()=>e.back(),{"data-back":""});j.disabled=p||a.step<=1;const _=x(e.label("guide_next"),"btn pri",()=>e.next());_.disabled=p;const y=x(e.label("didnt_work"),"link",()=>e.didntWork());y.disabled=p,b.append(s("div",{class:"row"},j,_),y)}return b}function M(){const a=e.entries;(a.length<f.length||a[0]!==f[0])&&(d.replaceChildren(),I=[],f=[]),a.forEach((l,b)=>{if(f[b]===l)return;const p=z(l);I[b]?l.kind==="card"?I[b].querySelectorAll(".row, .link").forEach(j=>j.remove()):I[b].replaceWith(p):(I[b]=p,d.append(p))}),a.forEach((l,b)=>{l.kind==="card"&&l.live&&I[b].querySelectorAll("button").forEach(p=>p.disabled=e.pending||p.hasAttribute("data-back")&&l.step<=1)}),f=[...a],d.querySelector(".dots")?.remove(),d.setAttribute("aria-busy",String(e.pending)),e.pending&&d.append(s("p",{class:"dots","aria-hidden":"true"},"…")),d.scrollTop=d.scrollHeight}function R(){const a=i.activeElement,l=a&&h.contains(a)?a.dataset.k:void 0,b=e.pending,p=[];e.error&&p.push(s("p",{class:"err",role:"status"},n(`error.${e.error}`)," ",x(n("try_again"),"link",()=>e.retry(),{"data-k":"retry"})));const j=e.tapOnly?e.chips():he(e.chips(),o.value),_=e.offers("other_need");if(j.length>0||_){const m=s("div",{class:"chips",role:"group","aria-label":n("suggestions")});for(const u of j){const E=x(u.badge?`${u.title} · ${u.badge}`:u.title,"chip job",()=>e.pickJob(u),{"data-k":`job:${u.jobId}`});E.disabled=b,m.append(E)}if(_){const u=x(e.label("other_need"),"chip",()=>e.other(),{"data-k":"other"});u.disabled=b,m.append(u)}p.push(m)}const y=s("div",{class:"row"});if(e.offers("guide_back")&&e.state!=="guide_step"&&y.append(x(e.label("guide_back"),"btn",()=>e.back(),{"data-k":"back"})),e.offers("talk_to_assistant")&&y.append(x(e.label("talk_to_assistant"),"btn",()=>e.talk(),{"data-k":"talk"})),e.offers("send")&&y.append(x(e.label("send"),"btn pri",()=>e.sendReport(),{"data-k":"send",...e.needsConsent()?{"aria-describedby":"jz-consent"}:{}})),y.querySelectorAll("button").forEach(m=>m.disabled=b),y.childElementCount>0&&p.push(y),e.needsConsent()){const m=x(e.label("consent")||n("allow"),"link",()=>{e.allow(),o.focus()},{"data-k":"allow"});p.push(s("p",{id:"jz-consent",class:e.consentAsked?"consent ask":"consent"},`${n("consent_line")} · `,m))}if(_e.includes(e.state)||e.offers("send")){const m=s("ul",{class:"ctx"});for(const u of e.contextChips()){const E=s("li",u.removable?{}:{class:"fixed"},u.label);u.removable&&E.append(x("✕","",()=>e.removeContext(u.key),{"aria-label":n("remove",{name:u.label}),"data-k":`ctx:${u.key}`})),m.append(E)}p.push(U("ctx",n("context.title"),m)),t.reviewer&&p.push(U("team",n("team.title"),W()))}if(e.attachments.length>0||e.anchor){const m=s("ul",{class:"atts","aria-label":n("attachments")});if(e.anchor){const u=n("pointed_at",{name:e.anchor.tflowId});m.append(s("li",{class:"pt"},u,x("✕","",()=>e.setAnchor(void 0),{"aria-label":n("remove",{name:u}),"data-k":"anchor"})))}e.attachments.forEach((u,E)=>{const B=u.label??n("attachment.screenshot",{n:E+1});m.append(s("li",{class:"att"},s("img",{src:u.thumbnail,alt:B}),x("✕","",()=>e.removeAttachment(u.id),{"aria-label":n("remove",{name:B}),"data-k":`att:${u.id}`})))}),p.push(m)}const J=e.state==="closed";o.disabled=e.tapOnly||J,o.placeholder=n(e.tapOnly?"input.tap_only":"input.placeholder"),S.textContent=e.tapOnly?n("input.paused"):"",O.disabled=o.disabled||b,k.hidden=e.plusItems().length===0,k.hidden&&!g.hidden&&w(false),h.replaceChildren(...p.filter(m=>!!m&&typeof m!="string")),e.consentAsked?h.querySelector("[data-k=allow]")?.focus():l&&(h.querySelector(`[data-k="${l}"]`)??(o.disabled?h.querySelector("button"):o))?.focus()}function U(a,l,b){const p=s("details",{},s("summary",{},l),b);return p.open=T[a],p.addEventListener("toggle",()=>T[a]=p.open),p}function W(){const a=(l,b,p,j)=>{const _=s("select",{},s("option",{value:""},"—"),...b.map(y=>s("option",{value:y},n(`team.${l}.${y}`))));return _.value=p??"",_.addEventListener("change",()=>j(_.value)),s("label",{},n(`team.${l}`),_)};return s("div",{class:"team"},a("verdict",we,e.team.verdict,l=>e.setTeam({verdict:l||void 0})),a("severity",ye,e.team.severity,l=>e.setTeam({severity:l||void 0})))}function P(){v.hidden||(M(),R())}const G=e.subscribe(P);return{open:F,close:A,isOpen:()=>!v.hidden,suspend(){w(false);const a=!v.hidden;return v.hidden=true,r.hidden=true,()=>{r.hidden=false,a&&(v.hidden=false,P(),(k.hidden?o:k).focus())}},destroy(){G(),r.remove(),v.remove()}}}const je=["desktop","tablet","mobile"];function K(i,e){const t=window.innerWidth,n=e.device&&je.includes(e.device)?e.device:t<768?"mobile":t<1024?"tablet":"desktop",r=i.signals?.appVersion;return{pagePath:i.pagePath==="none"?"":ie(location.href).slice(0,512),persona:e.persona,browser:fe(navigator.userAgent),device:n,viewport:{w:Math.min(t,2e4),h:Math.min(window.innerHeight,2e4)},build:r&&r.length<=64?r:void 0}}async function Ie(i,e,t){const n=await t?.(),r={siteKey:e.siteKey,...e.reviewerToken?{reviewerToken:e.reviewerToken}:{},...n?{claims:n}:{}};return q(i,"GetHelpIndex",r).then(d=>d.jobs??[])}function N(i,e){return i.flatMap(t=>{if(!t.jobId||!t.title)return[];const n=t.stepCount;return[{type:"chip",jobId:t.jobId,title:t.title,label:t.title,badge:n?n===1?e("chip.one_step"):e("chip.steps",{n}):e("chip.no_guide"),...n?{steps:n}:{}}]})}function V(i,e,t={}){const n=ee(i),r=i.claims!==void 0||i.getToken?import("./claims-BfpRuIu-.js").then(f=>f.claimsSource(i)):void 0,d=r&&(()=>r.then(f=>f.token()));d?.();const h=document.createElement("div");h.setAttribute("data-journeeze-chat","");const o=h.attachShadow({mode:"closed"}),S=document.createElement("style");S.textContent=ke,i.nonce&&(S.nonce=i.nonce),o.append(S),document.body.append(h);let k;const g=()=>k??(k=q(n,"GetWidgetConfig",{siteKey:i.siteKey}).catch(f=>{throw k=void 0,f})),O=(t.loadJobs??(()=>Ie(n,i,d)))().catch(()=>[]);let C,v=false;const I=g().then(f=>f.copy,()=>{}).then(async f=>{if(v)return;const T=pe(f),$=()=>i.reviewerToken||i.userId?void 0:null,w=new D({siteKey:i.siteKey,reviewer:!!i.reviewerToken,transport:t.transport??le(n,i,void 0,d),t:T,facts:()=>K(i,e()),hasConsent:()=>ne(H(i),$()),giveConsent:()=>te(H(i),$())}),F=z=>import("./attach-D451Wj4h.js").then(M=>M.plusItem(z,{session:w,root:o,options:i,endpoint:n,claims:d,config:g,suspend:()=>A.suspend()}),()=>w.note(T("note.capture_unavailable"))),A=Ce(o,w,{reviewer:!!i.reviewerToken,onPlusItem:t.onPlusItem??(z=>{F(z)})});C={session:w,view:A},w.start(N(await O,T))});return{unmount(){v=true,r?.then(f=>f.stop()),C?.view.destroy(),h.remove()},report(){I.then(()=>{C?.view.open(),C?.session.reportProblem()})},addAttachment:f=>!!C?.session.addAttachment(f),removeAttachment:f=>C?.session.removeAttachment(f)}}const Ae=(i,e)=>V(i,()=>re(e())),Te=Object.freeze(Object.defineProperty({__proto__:null,jobChips:N,mount:Ae,mountChat:V,pageFacts:K},Symbol.toStringTag,{value:"Module"}));export{ge as M,Te as c,L as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{w as f}from"./loader-k4pePzAw.js";const g=/^[A-Za-z0-9_-]{1,4000}\.[A-Za-z0-9_-]{43}$/,E=4096,A=60,S=15e3;function _(e){return typeof e=="string"&&e.length<=E&&g.test(e)}function p(e){try{const t=(e.split(".")[0]??"").replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(t+"=".repeat((4-t.length%4)%4)))}catch{return{}}}const d=e=>typeof e=="number"&&Number.isInteger(e)?e:void 0;function M(e){return d(p(e).exp)}const l=new Map;function y(e,t=Date.now()){const i=p(e),r=d(i.exp),s=d(i.iat);if(r===void 0||s===void 0)return;let c=l.get(e);return c===void 0&&(l.size>=32&&l.clear(),l.set(e,c=t)),c+(r-s)*1e3}function a(e,t=0,i=Date.now()){if(!_(e))return;const r=y(e,i);return r!==void 0&&r-i>t*1e3?e:void 0}function N(e,t=Date.now){let i=false,r,s=-1/0;const c=async o=>{let n;s=t();try{n=await o()}catch{f("getToken failed")}if(!i)return a(n,0,t())?(e.claims=n,n):(n!==void 0&&f("invalid claims token ignored"),a(e.claims,0,t()))},m={token(){if(i)return Promise.resolve(void 0);const o=t(),n=a(e.claims,A,o);if(n)return Promise.resolve(n);const v=e.getToken,u=a(e.claims,0,o);return typeof v!="function"?(e.claims!==void 0&&!_(e.claims)&&f("invalid claims token ignored"),Promise.resolve(u)):!r&&u&&o-s<S?Promise.resolve(u):(r??(r=c(v).finally(()=>r=void 0)),r)},current(){if(!i)return m.token(),a(e.claims,0,t())},stop(){i=true}};return m}export{S as CLAIMS_MIN_REFRESH_INTERVAL_MS,A as CLAIMS_REFRESH_MARGIN_S,E as CLAIMS_TOKEN_MAX_LEN,g as CLAIMS_TOKEN_PATTERN,y as claimsEnd,M as claimsExp,N as claimsSource,a as usableClaims,_ as wellFormedClaims};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var v=Object.defineProperty;var w=(e,t,n)=>t in e?v(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var u=(e,t,n)=>w(e,typeof t!="symbol"?t+"":t,n);import{CONTEXT_FIELDS as S,CONTEXT_VALUE_MAX_LEN as T,CONTEXT_ID_PATTERN as E,API_PATH_PATTERN as N}from"./contract.js";import{w as c,p as _}from"./loader-k4pePzAw.js";class m extends Error{constructor(n,r,o=0,i){super(r);u(this,"code");u(this,"status");u(this,"retryAfterMs");this.code=n,this.status=o,this.retryAfterMs=i}}const I="https://app.journeeze.dev",b=15e3;function C(e,t=b){return typeof AbortSignal<"u"&&typeof AbortSignal.timeout=="function"?{...e,signal:AbortSignal.timeout(t)}:e}function $(e,t=location.href){try{return new URL(e,t).origin!==new URL(t).origin}catch{return true}}const k="text/plain;charset=UTF-8";function A(e,t){return`${e.replace(/\/+$/,"")}/journeeze.collector.v1.CollectorService/${t}`}function O(e,t){const n=$(e)?{"content-type":k}:{"content-type":"application/json","connect-protocol-version":"1"};return t?{...n,"if-none-match":t}:n}function y(e,t,n,r,o){const i=C({method:"POST",headers:O(e,o.etag),body:JSON.stringify(n),credentials:"omit",cache:"no-store",referrerPolicy:"no-referrer",...o.keepalive?{keepalive:true}:{}});return r(A(e,t),i)}const x=6e4;function j(e,t=Date.now()){if(!e)return;const n=Number(e.trim()),r=Number.isFinite(n)&&/^\d+$/.test(e.trim())?n*1e3:Date.parse(e)-t;return Number.isFinite(r)?Math.min(Math.max(r,0),x):void 0}async function g(e){const t=await e.json().catch(()=>{});if(!e.ok){const n=typeof t?.code=="string"?t.code:M(e.status);throw new m(n,String(t?.message??e.statusText),e.status,j(e.headers.get("retry-after")))}if(t===void 0||typeof t!="object"||t===null)throw new m("unavailable","the collector did not answer with Connect JSON",e.status);return t}async function D(e,t,n,r=fetch,o={}){return g(await y(e,t,n,r,o.keepalive?{keepalive:true}:{}))}async function F(e,t,n,r,o=fetch){const i=await y(e,t,n,o,r?{etag:r}:{});if(i.status===304)return{notModified:true};const s=await g(i),a=i.headers.get("etag");return a?{notModified:false,value:s,etag:a}:{notModified:false,value:s}}function H(e,t){return t?`${e.replace(/\/+$/,"")}${t.startsWith("/")?"":"/"}${t}`:void 0}function M(e){return e===401?"unauthenticated":e===403?"permission_denied":e===409?"already_exists":e===412?"failed_precondition":e===429?"resource_exhausted":e===404||e===408||e>=500?"unavailable":e>=400?"invalid_argument":"unknown"}function X(e,t=location.href){const{endpoint:n,apiHost:r,apiPath:o}=e;if(n!==void 0)return c("endpoint is deprecated; use apiHost"),new URL(n,t).href.replace(/\/+$/,"");let i=I;if(r!==void 0){const s=r.replace(/\/$/,"");let a=false;try{const f=new URL(s);a=f.origin===s&&(f.protocol==="https:"||/^(localhost|127\.0\.0\.1)$/.test(f.hostname))}catch{}a?i=s:c("invalid apiHost ignored")}return o===void 0?i:N.test(o)?i+o:(c("invalid apiPath ignored"),i)}function z(e){const t={};for(const n of S){if(!(n in e))continue;const r=e[n]||void 0;if(r!==void 0&&(typeof r!="string"||r.length>T||/[\0-\x1f\x7f]/.test(r))){c(`context.${n} dropped (1..=128 printable characters)`),t[n]=void 0;continue}r!==void 0&&!E.test(r)&&c(`context.${n} should be an id`),t[n]=r}return t}const P=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$|[0-9a-f]{16}|@|^[\w-]{24,}$/i;function J(e){return _(e).split("/").map(t=>{let n=t;try{n=decodeURIComponent(t)}catch{}return P.test(n)?":id":t}).join("/")}function Y(e){const t=e.signature===void 0?e.userIdSig:e.signature?e.signature.sig:void 0,n=e.signature===void 0?e.userIdExp:e.signature?e.signature.exp:void 0;return typeof t!="string"||!/^[A-Za-z0-9_-]{43}$/.test(t)?{}:typeof n!="number"||!Number.isInteger(n)||n*1e3<=Date.now()?{}:{userIdSig:t,userIdExp:n}}const d=1,q="Feedback mode captures the element you point at, a screenshot of this page with form fields hidden, your comment, and your persona and journey step. It never records keystrokes, form contents or query strings. Your feedback is visible to the project's review team.",V="Feedback mode captures the element you point at, your comment, and your persona and journey step. No screenshot is sent. It never records keystrokes, form contents or query strings. Your feedback is visible to the project's review team.",l=e=>`jz:consent:v${d}:${e}`,p=new Set,B=e=>e.userId?`${e.siteKey}:u:${e.userId}`:e.siteKey;function G(e,t=h()){p.delete(e);try{t?.removeItem(l(e))}catch{}}function h(){try{return window.localStorage}catch{return}}function K(e,t=h()){if(p.has(e))return true;try{const n=t?.getItem(l(e));return n?JSON.parse(n).v===d:false}catch{return false}}function W(e,t=h()){p.add(e);try{t?.setItem(l(e),JSON.stringify({v:d,at:new Date().toISOString()}))}catch{}}export{m as C,q as D,x as R,k as T,h as a,G as b,D as c,X as d,z as e,B as f,V as g,K as h,W as i,Y as j,F as k,H as l,A as r,J as s,C as w};
|
package/dist/contract.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as t, U as A } from "./loader-
|
|
1
|
+
import { S as t, U as A } from "./loader-k4pePzAw.js";
|
|
2
2
|
const T = /^(?:\/[A-Za-z0-9._~-]+)+$/, _ = 128, E = /^[a-z0-9._:-]{1,96}$/, e = ["persona", "journeyId", "journeyStep", "device", "businessType", "state"];
|
|
3
3
|
export {
|
|
4
4
|
T as API_PATH_PATTERN,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var I=Object.defineProperty;var _=(s,e,t)=>e in s?I(s,e,{enumerable:true,configurable:true,writable:true,value:t}):s[e]=t;var h=(s,e,t)=>_(s,typeof e!="symbol"?e+"":e,t);import{C as w,a as v,c as f,b as q,d as x}from"./consent-BupCs23W.js";import{usableClaims as y}from"./claims-BfpRuIu-.js";const A=new Set(["invalid_argument","failed_precondition","permission_denied","unauthenticated","not_found","already_exists","unimplemented"]),g=50,O=1e3,T=6e4,b=1440*60*1e3;function L(s){return Math.min(T,O*2**Math.max(0,s))}function M(s){return s instanceof w&&A.has(s.code)}class D{constructor(e){h(this,"deps");h(this,"items",[]);h(this,"inFlight");h(this,"attempt",0);h(this,"flushing");h(this,"timer");h(this,"disposed",false);h(this,"schedule");h(this,"cancel");h(this,"now");this.deps=e,this.schedule=e.schedule??((t,i)=>setTimeout(t,i)),this.cancel=e.cancel??(t=>clearTimeout(t)),this.now=e.now??Date.now,this.claim()}get size(){return this.items.length}enqueue(e){return new Promise(t=>{const i={request:e,settle:t};this.add(i),this.flush().then(()=>{this.items.includes(i)&&u(i,"queued")})})}stash(e){this.add({request:e})}flush(){return this.disposed?Promise.resolve():(this.timer!==void 0&&(this.cancel(this.timer),this.timer=void 0),this.flushing?this.flushing.then(()=>this.timer===void 0?this.flush():void 0):(this.flushing=this.drain().finally(()=>{this.flushing=void 0}),this.flushing))}persist(){const e=this.items.filter(t=>t!==this.inFlight);if(!(e.length===0||!this.deps.storage))try{const t=this.read(),i=this.now(),n=this.deps.user?.(),a=[...t,...e.map(r=>({owner:this.deps.owner,request:r.request,at:r.at??i,...n?{user:n}:{}}))].slice(-g);this.deps.storage?.setItem(this.deps.storageKey,JSON.stringify(a));for(const r of e)u(r,"queued");this.items=this.items.filter(r=>r===this.inFlight)}catch{}}claim(){try{const e=this.read(),t=e.filter(n=>n.owner===this.deps.owner);if(t.length===0)return;const i=e.filter(n=>n.owner!==this.deps.owner);i.length===0?this.deps.storage?.removeItem(this.deps.storageKey):this.deps.storage?.setItem(this.deps.storageKey,JSON.stringify(i));for(const n of t)this.fresh(n)&&this.add({request:n.request,at:n.at})}catch{}}dispose(){this.persist(),this.disposed=true,this.timer!==void 0&&this.cancel(this.timer),this.timer=void 0}add(e){var t;for((t=e.request).submissionId??(t.submissionId=P()),this.items.push(e);this.items.length>g;){const i=this.items[0]===this.inFlight?1:0,[n]=this.items.splice(i,1);n&&u(n,"dropped")}}async drain(){for(;!this.disposed;){const e=this.items[0];if(!e){this.attempt=0;return}this.inFlight=e;try{await this.deps.send(e.request),this.remove(e),this.attempt=0,u(e,"sent")}catch(t){if(M(t)){this.remove(e),u(e,"dropped"),this.deps.onDropped?.(t);continue}if(this.disposed){this.inFlight=void 0,this.persist();return}const i=L(this.attempt++);this.timer=this.schedule(()=>{this.timer=void 0,this.flush()},i);return}finally{this.inFlight=void 0}}}fresh(e){return e.at===void 0?true:typeof e.at=="number"&&Number.isFinite(e.at)&&this.now()-e.at<=b}remove(e){const t=this.items.indexOf(e);t>=0&&this.items.splice(t,1)}read(){const e=this.deps.storage?.getItem(this.deps.storageKey),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(i=>typeof i=="object"&&i!==null&&typeof i.owner=="string"&&typeof i.request=="object"&&i.request!==null):[]}}function F(s){if(!s)return"";let e=2166136261;for(let t=0;t<s.length;t++)e^=s.charCodeAt(t),e=Math.imul(e,16777619)>>>0;return e.toString(16).padStart(8,"0")}function P(){return crypto.randomUUID()}function u(s,e){const t=s.settle;s.settle=void 0,t?.(e)}function C(s,e,t,i=Date.now()){try{const n=s?.getItem(e),a=n?JSON.parse(n):[],r=Array.isArray(a)?a:[],c=r.filter(o=>o?.owner===t),d=r.filter(o=>o?.owner!==t);return d.length===0?s?.removeItem(e):s?.setItem(e,JSON.stringify(d)),c.filter(o=>o.request&&(o.at===void 0||i-o.at<=b)).sort((o,l)=>(o.at??0)-(l.at??0)).map(o=>o.request)}catch{return[]}}const S=s=>F(s.reviewerToken||(s.userId?`u:${s.userId}`:void 0)),N=32*1024;async function z(s){const e=C(v(),`jz:outbox:v2:${s.siteKey}`,S(s));if(q(s.siteKey),e.length===0)return;const t=x(s);let i=N;const n=(c,d)=>f(t,"SubmitFeedback",c,fetch,{keepalive:d}),r=(await Promise.allSettled(e.map(c=>{const d=E(s,c,y(s.claims)),o=new Blob([JSON.stringify(d)]).size,l=o<=i;l&&(i-=o);const m=n(d,l);return l?m.catch(p=>p instanceof w?Promise.reject(p):n(d,false)):m}))).filter(c=>c.status==="rejected").length;r&&console.warn(`[journeeze] ${r} feedback item(s) could not be sent at logout and were discarded`)}function E(s,e,t){const i=s.reviewerToken?{...e,reviewerToken:s.reviewerToken}:{...e};if(t&&(i.claims=t),s.pagePath==="none"){const{pagePath:n,...a}=i.context;i.context=a}return i}function J(s,e,t={}){const i=d=>(t.claims?.(),f(e,"SubmitFeedback",E(s,d,y(s.claims)),fetch,{keepalive:true}).then(()=>{})),n=new D({send:i,storage:t.memoryOnly?void 0:v(),storageKey:`jz:outbox:v2:${s.siteKey}`,owner:S(s),user:()=>s.userId,...t.onDropped?{onDropped:t.onDropped}:{}}),a=()=>{n.flush()},r=()=>{t.beforePersist?.(),n.persist()},c=d=>{d.persisted&&(n.claim(),n.flush())};return window.addEventListener("online",a),window.addEventListener("pagehide",r),window.addEventListener("pageshow",c),{outbox:n,dispose(){window.removeEventListener("online",a),window.removeEventListener("pagehide",r),window.removeEventListener("pageshow",c),n.dispose()}}}function B(s,e){return f(s,"GetWidgetConfig",{siteKey:e})}export{J as feedbackChannel,z as logout,S as ownerOf,B as widgetConfig};
|