@prosopo/client-bundle-example 2.10.23 → 2.11.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.
Files changed (51) hide show
  1. package/.turbo/turbo-build$colon$cjs.log +5 -4
  2. package/.turbo/turbo-build$colon$tsc.log +11 -11
  3. package/.turbo/turbo-build.log +6 -5
  4. package/CHANGELOG.md +21 -0
  5. package/dist/cjs/index.cjs +13 -41
  6. package/dist/cjs/plugins/pages.cjs +113 -0
  7. package/dist/index.js +2 -42
  8. package/dist/plugins/pages.js +103 -0
  9. package/package.json +7 -7
  10. package/src/frictionless-explicit-web3.html +10 -23
  11. package/src/frictionless-explicit.html +18 -22
  12. package/src/frictionless-implicit.html +60 -86
  13. package/src/frictionless-manual-start.html +13 -33
  14. package/src/image-explicit-web3.html +8 -24
  15. package/src/image-explicit.html +16 -23
  16. package/src/image-implicit.html +192 -0
  17. package/src/index.html +11 -26
  18. package/src/index.ts +1 -62
  19. package/src/invisible-frictionless-explicit.html +8 -17
  20. package/src/invisible-frictionless-implicit.html +8 -25
  21. package/src/invisible-image-explicit.html +8 -23
  22. package/src/invisible-image-implicit.html +8 -24
  23. package/src/invisible-pow-explicit.html +8 -23
  24. package/src/invisible-pow-implicit.html +9 -21
  25. package/src/invisible-puzzle-explicit.html +8 -23
  26. package/src/invisible-puzzle-implicit.html +9 -21
  27. package/src/plugins/code-snippet-injector.ts +179 -0
  28. package/src/plugins/form-filler-injector.ts +36 -121
  29. package/src/plugins/layout-injector.ts +238 -0
  30. package/src/plugins/logo.ts +15 -0
  31. package/src/plugins/pages.ts +219 -0
  32. package/src/plugins/placement-injector.ts +114 -0
  33. package/src/plugins/slots.ts +32 -0
  34. package/src/plugins/status-log-injector.ts +35 -114
  35. package/src/pow-explicit-web3.html +8 -24
  36. package/src/pow-explicit.html +8 -23
  37. package/src/pow-implicit-sessionid.html +10 -24
  38. package/src/pow-implicit.html +9 -24
  39. package/src/puzzle-bind-explicit.html +83 -0
  40. package/src/puzzle-explicit.html +16 -23
  41. package/src/puzzle-implicit.html +9 -24
  42. package/src/styles/demo.css +803 -0
  43. package/src/tests/plugins.unit.test.ts +285 -118
  44. package/tsconfig.tsbuildinfo +1 -1
  45. package/vite.config.ts +11 -5
  46. package/src/plugins/explanation-injector.ts +0 -294
  47. package/src/plugins/navigation-injector.ts +0 -605
  48. package/src/styles/captcha.css +0 -78
  49. package/src/styles/field.css +0 -12
  50. package/src/tests/floatLabel.unit.test.ts +0 -195
  51. package/src/tests/floatLabelReady.unit.test.ts +0 -36
@@ -1,195 +0,0 @@
1
- // Copyright 2021-2026 Prosopo (UK) Ltd.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- // @vitest-environment jsdom
16
-
17
- // src/index.ts is a self-executing float-label script: it hides the label of
18
- // any wrapper whose input is focused or non-empty. It runs at import time, so
19
- // each test seeds the DOM first and then imports it with a fresh module registry.
20
-
21
- import {
22
- afterEach,
23
- beforeAll,
24
- beforeEach,
25
- describe,
26
- expect,
27
- it,
28
- vi,
29
- } from "vitest";
30
-
31
- const WRAPPER = "mui-textfield--float-label";
32
- const HIDDEN = "label-hidden";
33
-
34
- const seed = (markup: string): void => {
35
- document.body.innerHTML = markup;
36
- };
37
-
38
- const wrapper = (inner: string): string =>
39
- `<div class="${WRAPPER}">${inner}</div>`;
40
-
41
- // The script is a side-effecting IIFE that runs exactly once per module
42
- // evaluation, and vitest will not re-evaluate it per test. So it is imported
43
- // once with document.readyState pinned to "loading": that makes it register a
44
- // DOMContentLoaded listener instead of running immediately, and each test then
45
- // dispatches that event to run the script against its own freshly seeded DOM.
46
- // (floatLabelReady.unit.test.ts covers the already-loaded branch.)
47
- beforeAll(async () => {
48
- vi.spyOn(document, "readyState", "get").mockReturnValue("loading");
49
- await import("../index.js");
50
- });
51
-
52
- const load = (): void => {
53
- document.dispatchEvent(new Event("DOMContentLoaded"));
54
- };
55
-
56
- beforeEach(() => {
57
- vi.useFakeTimers();
58
- document.body.innerHTML = "";
59
- });
60
-
61
- afterEach(() => {
62
- vi.useRealTimers();
63
- });
64
-
65
- describe("float label script", () => {
66
- it("hides the label of a pre-filled input", async () => {
67
- seed(wrapper('<label>Email</label><input value="a@test.com" />'));
68
-
69
- load();
70
-
71
- expect(document.querySelector(`.${WRAPPER}`)?.classList).toContain(HIDDEN);
72
- });
73
-
74
- it("leaves the label visible for an empty input", async () => {
75
- seed(wrapper("<label>Email</label><input />"));
76
-
77
- load();
78
-
79
- expect(document.querySelector(`.${WRAPPER}`)?.classList).not.toContain(
80
- HIDDEN,
81
- );
82
- });
83
-
84
- it("treats a whitespace-only value as empty", async () => {
85
- seed(wrapper('<label>Email</label><input value=" " />'));
86
-
87
- load();
88
-
89
- expect(document.querySelector(`.${WRAPPER}`)?.classList).not.toContain(
90
- HIDDEN,
91
- );
92
- });
93
-
94
- it("hides the label once the input receives a value", async () => {
95
- seed(wrapper("<label>Email</label><input />"));
96
- load();
97
- const input = document.querySelector("input");
98
- if (!input) throw new Error("input missing");
99
-
100
- input.value = "typed";
101
- input.dispatchEvent(new Event("input", { bubbles: true }));
102
-
103
- expect(document.querySelector(`.${WRAPPER}`)?.classList).toContain(HIDDEN);
104
- });
105
-
106
- it("restores the label when the value is cleared", async () => {
107
- seed(wrapper('<label>Email</label><input value="typed" />'));
108
- load();
109
- const input = document.querySelector("input");
110
- if (!input) throw new Error("input missing");
111
-
112
- input.value = "";
113
- input.dispatchEvent(new Event("input", { bubbles: true }));
114
-
115
- expect(document.querySelector(`.${WRAPPER}`)?.classList).not.toContain(
116
- HIDDEN,
117
- );
118
- });
119
-
120
- it("hides the label for a checked checkbox", async () => {
121
- seed(wrapper('<label>Agree</label><input type="checkbox" checked />'));
122
-
123
- load();
124
-
125
- expect(document.querySelector(`.${WRAPPER}`)?.classList).toContain(HIDDEN);
126
- });
127
-
128
- it("leaves the label visible for an unchecked checkbox", async () => {
129
- seed(wrapper('<label>Agree</label><input type="checkbox" />'));
130
-
131
- load();
132
-
133
- expect(document.querySelector(`.${WRAPPER}`)?.classList).not.toContain(
134
- HIDDEN,
135
- );
136
- });
137
-
138
- it("copies the label text into aria-label for screen readers", async () => {
139
- seed(wrapper("<label> Email </label><input />"));
140
-
141
- load();
142
-
143
- expect(document.querySelector("input")?.getAttribute("aria-label")).toBe(
144
- "Email",
145
- );
146
- });
147
-
148
- it("does not overwrite an explicit aria-label", async () => {
149
- seed(wrapper('<label>Email</label><input aria-label="Your email" />'));
150
-
151
- load();
152
-
153
- expect(document.querySelector("input")?.getAttribute("aria-label")).toBe(
154
- "Your email",
155
- );
156
- });
157
-
158
- it("also drives a textarea", async () => {
159
- seed(wrapper("<label>Notes</label><textarea>filled</textarea>"));
160
-
161
- load();
162
-
163
- expect(document.querySelector(`.${WRAPPER}`)?.classList).toContain(HIDDEN);
164
- });
165
-
166
- it("does nothing when there are no wrappers", async () => {
167
- seed("<div><input /></div>");
168
-
169
- expect(() => load()).not.toThrow();
170
- });
171
-
172
- it("tolerates a wrapper with no label", async () => {
173
- seed(wrapper("<input />"));
174
-
175
- expect(() => load()).not.toThrow();
176
- });
177
-
178
- it("polls for autofill and stops after roughly three seconds", async () => {
179
- seed(wrapper('<label>Email</label><input value="" />'));
180
- load();
181
- const input = document.querySelector("input");
182
- if (!input) throw new Error("input missing");
183
- const spy = vi.spyOn(input, "dispatchEvent");
184
-
185
- // the browser fills the field without emitting an event; the poll picks it up
186
- input.value = "autofilled@test.com";
187
- vi.advanceTimersByTime(250);
188
-
189
- expect(document.querySelector(`.${WRAPPER}`)?.classList).toContain(HIDDEN);
190
-
191
- // 12 checks at 250ms, then the interval clears itself
192
- vi.advanceTimersByTime(10_000);
193
- expect(spy.mock.calls.length).toBeLessThanOrEqual(12);
194
- });
195
- });
@@ -1,36 +0,0 @@
1
- // Copyright 2021-2026 Prosopo (UK) Ltd.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- // @vitest-environment jsdom
16
-
17
- // Covers the branch of src/index.ts taken when the document has already
18
- // finished loading: the script must run straight away rather than waiting for
19
- // DOMContentLoaded. Kept in its own file because the IIFE only evaluates once
20
- // per module instance. The waiting branch is covered by floatLabel.unit.test.ts.
21
-
22
- import { describe, expect, it } from "vitest";
23
-
24
- describe("float label script — document already loaded", () => {
25
- it("applies the label state immediately on import", async () => {
26
- document.body.innerHTML =
27
- '<div class="mui-textfield--float-label"><label>Email</label><input value="a@test.com" /></div>';
28
- expect(document.readyState).not.toBe("loading");
29
-
30
- await import("../index.js");
31
-
32
- expect(
33
- document.querySelector(".mui-textfield--float-label")?.classList,
34
- ).toContain("label-hidden");
35
- });
36
- });