feat(demo): add story 1 — Sorano: Rock and Time

This commit is contained in:
2026-06-20 21:19:57 +02:00
parent 42ed59a6b3
commit 8f87155c1d
5508 changed files with 1595740 additions and 124 deletions
+13
View File
@@ -0,0 +1,13 @@
Copyright 2025 Tiago
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+23
View File
@@ -0,0 +1,23 @@
# Cap widget (vendored)
Vendored from:
- `@cap.js/widget` (see `VERSION`)
- `@cap.js/wasm@0.0.6``cap_wasm_bg.wasm`
Upstream: https://github.com/tiagozip/cap
## Updating
```bash
npm pack @cap.js/widget
npm pack @cap.js/wasm
# extract and copy cap.min.js, cap.d.ts, wasm-hashes.min.js, LICENSE
# and browser/cap_wasm_bg.wasm into this directory, then update VERSION.
```
## Why vendored
The upstream widget fetches its WASM module from `cdn.jsdelivr.net` by
default. We set `window.CAP_CUSTOM_WASM_URL` to the locally vendored
copy so Cap captcha works fully self-hosted with no third-party runtime
dependency — matching the privacy-preserving ethos of the project.
+1
View File
@@ -0,0 +1 @@
0.1.43
+120
View File
@@ -0,0 +1,120 @@
declare global {
interface Window {
CAP_CUSTOM_FETCH?: typeof fetch;
CAP_CUSTOM_WASM_URL?: string;
CAP_CSS_NONCE?: string;
CAP_DONT_SKIP_REDEFINE?: boolean;
Cap: typeof Cap;
}
}
interface CapProgressEventDetail {
progress: number;
}
interface CapSolveEventDetail {
token: string;
}
interface CapErrorEventDetail {
isCap: boolean;
message: string;
}
interface CapProgressEvent extends CustomEvent {
detail: CapProgressEventDetail;
}
interface CapSolveEvent extends CustomEvent {
detail: CapSolveEventDetail;
}
interface CapErrorEvent extends CustomEvent {
detail: CapErrorEventDetail;
}
interface CapResetEvent extends CustomEvent {
detail: Record<string, never>;
}
interface SolveResult {
success: boolean;
token: string;
}
interface CapConfig {
apiEndpoint?: string;
"data-cap-api-endpoint"?: string;
"data-cap-worker-count"?: string;
"data-cap-hidden-field-name"?: string;
"data-cap-i18n-initial-state"?: string;
"data-cap-i18n-verifying-label"?: string;
"data-cap-i18n-solved-label"?: string;
"data-cap-i18n-error-label"?: string;
"data-cap-i18n-verify-aria-label"?: string;
"data-cap-i18n-verifying-aria-label"?: string;
"data-cap-i18n-verified-aria-label"?: string;
"data-cap-i18n-error-aria-label"?: string;
"data-cap-i18n-wasm-disabled"?: string;
"data-cap-troubleshooting-url"?: string;
onsolve?: string;
onprogress?: string;
onreset?: string;
onerror?: string;
}
interface CapWidget extends HTMLElement {
readonly token: string | null;
readonly tokenValue: string | null;
solve(): Promise<SolveResult>;
reset(): void;
setWorkersCount(workers: number): void;
addEventListener(type: "progress", listener: (event: CapProgressEvent) => void): void;
addEventListener(type: "solve", listener: (event: CapSolveEvent) => void): void;
addEventListener(type: "error", listener: (event: CapErrorEvent) => void): void;
addEventListener(type: "reset", listener: (event: CapResetEvent) => void): void;
addEventListener(type: string, listener: EventListener): void;
removeEventListener(type: "progress", listener: (event: CapProgressEvent) => void): void;
removeEventListener(type: "solve", listener: (event: CapSolveEvent) => void): void;
removeEventListener(type: "error", listener: (event: CapErrorEvent) => void): void;
removeEventListener(type: "reset", listener: (event: CapResetEvent) => void): void;
removeEventListener(type: string, listener: EventListener): void;
}
declare class Cap {
readonly widget: CapWidget;
readonly token: string | null;
constructor(config?: CapConfig, el?: CapWidget);
solve(): Promise<SolveResult>;
reset(): void;
addEventListener(type: "progress", listener: (event: CapProgressEvent) => void): void;
addEventListener(type: "solve", listener: (event: CapSolveEvent) => void): void;
addEventListener(type: "error", listener: (event: CapErrorEvent) => void): void;
addEventListener(type: "reset", listener: (event: CapResetEvent) => void): void;
addEventListener(type: string, listener: EventListener): void;
}
declare global {
interface HTMLElementTagNameMap {
"cap-widget": CapWidget;
}
}
export {
Cap,
type CapWidget,
type CapConfig,
type CapProgressEvent,
type CapSolveEvent,
type CapErrorEvent,
type CapResetEvent,
type SolveResult,
};
export default Cap;
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long