@prosopo/client-bundle-example 2.10.24 → 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.
- package/.turbo/turbo-build$colon$cjs.log +5 -4
- package/.turbo/turbo-build$colon$tsc.log +11 -11
- package/.turbo/turbo-build.log +6 -5
- package/CHANGELOG.md +16 -0
- package/dist/cjs/index.cjs +13 -41
- package/dist/cjs/plugins/pages.cjs +113 -0
- package/dist/index.js +2 -42
- package/dist/plugins/pages.js +103 -0
- package/package.json +2 -2
- package/src/frictionless-explicit-web3.html +10 -23
- package/src/frictionless-explicit.html +10 -22
- package/src/frictionless-implicit.html +60 -86
- package/src/frictionless-manual-start.html +13 -33
- package/src/image-explicit-web3.html +8 -24
- package/src/image-explicit.html +8 -23
- package/src/image-implicit.html +192 -0
- package/src/index.html +11 -26
- package/src/index.ts +1 -62
- package/src/invisible-frictionless-explicit.html +8 -17
- package/src/invisible-frictionless-implicit.html +8 -25
- package/src/invisible-image-explicit.html +8 -23
- package/src/invisible-image-implicit.html +8 -24
- package/src/invisible-pow-explicit.html +8 -23
- package/src/invisible-pow-implicit.html +9 -21
- package/src/invisible-puzzle-explicit.html +8 -23
- package/src/invisible-puzzle-implicit.html +9 -21
- package/src/plugins/code-snippet-injector.ts +179 -0
- package/src/plugins/form-filler-injector.ts +36 -121
- package/src/plugins/layout-injector.ts +238 -0
- package/src/plugins/logo.ts +15 -0
- package/src/plugins/pages.ts +219 -0
- package/src/plugins/placement-injector.ts +25 -64
- package/src/plugins/slots.ts +32 -0
- package/src/plugins/status-log-injector.ts +35 -114
- package/src/pow-explicit-web3.html +8 -24
- package/src/pow-explicit.html +8 -23
- package/src/pow-implicit-sessionid.html +10 -24
- package/src/pow-implicit.html +9 -24
- package/src/puzzle-bind-explicit.html +9 -24
- package/src/puzzle-explicit.html +8 -23
- package/src/puzzle-implicit.html +9 -24
- package/src/styles/demo.css +803 -0
- package/src/tests/plugins.unit.test.ts +285 -118
- package/tsconfig.tsbuildinfo +1 -1
- package/vite.config.ts +5 -5
- package/src/plugins/explanation-injector.ts +0 -294
- package/src/plugins/navigation-injector.ts +0 -606
- package/src/styles/captcha.css +0 -78
- package/src/styles/field.css +0 -12
- package/src/tests/floatLabel.unit.test.ts +0 -195
- 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
|
-
});
|