layerpro 3.4.0 → 4.0.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/README.md +41 -36
- package/SECURITY-HARDENING.md +265 -0
- package/SECURITY.md +8 -0
- package/global.cjs +974 -0
- package/global.d.ts +27 -0
- package/global.js +974 -0
- package/index.cjs +415 -383
- package/index.css +4 -5
- package/index.js +415 -383
- package/llms.txt +3 -1
- package/markdown/GUIDE.md +14 -15
- package/package.json +10 -4
- package/types/layerpro.d.ts +134 -143
package/llms.txt
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
- [core/dom.ts](core/dom.ts): jQuery-free chainable DOM helper (`LpEl`, `lp`, `lpAll`, `lpCreate`, `lpDoc`, `lpWin`) - the replacement for jQuery.
|
|
12
12
|
- [core/properties.ts](core/properties.ts): The `popup` object - `open`, `close`, `center`, `maximize`, `iconize`, `index`, `zIndex`, `movable`, `resizable`, `cleanupEvents`, `unmount`.
|
|
13
13
|
- [core/genLayer.ts](core/genLayer.ts): DOM builder for a popup, dock/buttons wiring, pointer/click/dblclick handlers.
|
|
14
|
-
- [core/
|
|
14
|
+
- [core/accessibility.ts](core/accessibility.ts): ARIA attributes, focus save/restore, Tab focus trap.
|
|
15
|
+
- [core/message.ts](core/message.ts): `alert`/`confirm`/`message`/`prompt` - Promise-based (resolve on close); in 4.0 globals are opt-in via `layerpro/global`, `noGlobals` is removed.
|
|
15
16
|
- [core/mode.ts](core/mode.ts): Close popups on orientation/size mode switch.
|
|
16
17
|
- [core/mobile.ts](core/mobile.ts): Unified pointer/mouse/touch events (`getPointerDown`/`getPointerMove`/`getPointerUp`).
|
|
17
18
|
- [core/window.ts](core/window.ts): Window-level helpers (scroll, size).
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
- [docs/README.md](docs/README.md): Project README (features, install, quick start).
|
|
28
29
|
- [docs/markdown/GUIDE.md](docs/markdown/GUIDE.md): Example-driven usage guide (modals, popups, dock, maximize, resize, React body, API).
|
|
29
30
|
- [docs/llms.txt](docs/llms.txt): This file.
|
|
31
|
+
- [docs/SECURITY-HARDENING.md](docs/SECURITY-HARDENING.md): Security reference (CSP, XSS, SSRF, global overrides, accessibility).
|
|
30
32
|
|
|
31
33
|
## Build & Config
|
|
32
34
|
|
package/markdown/GUIDE.md
CHANGED
|
@@ -53,15 +53,14 @@ import "layerpro";
|
|
|
53
53
|
That single import is enough - `window.layerpro` becomes available and the
|
|
54
54
|
global `alert`/`confirm`/`prompt` are replaced, and a `message` global is added.
|
|
55
55
|
|
|
56
|
-
> **⚠️ Global override
|
|
57
|
-
> `
|
|
58
|
-
>
|
|
59
|
-
>
|
|
60
|
-
> importing to restore the originals:
|
|
56
|
+
> **⚠️ Global override note:** in 4.0, `import 'layerpro'` does **not** override
|
|
57
|
+
> `window.alert`/`confirm`/`prompt`/`message`. The library methods
|
|
58
|
+
> (`layerpro.alert`, `layerpro.confirm`, etc.) return Promises. To override the
|
|
59
|
+
> browser globals with Promise-based versions, import the explicit entry point:
|
|
61
60
|
>
|
|
62
61
|
> ```javascript
|
|
63
|
-
> import "layerpro";
|
|
64
|
-
>
|
|
62
|
+
> import "layerpro/global"; // opt-in to global overrides
|
|
63
|
+
> await confirm("Sure?"); // Promise<boolean>
|
|
65
64
|
> ```
|
|
66
65
|
|
|
67
66
|
---
|
|
@@ -169,17 +168,16 @@ layerpro.popup.open({
|
|
|
169
168
|
iconize?: boolean, // allow minimize to dock
|
|
170
169
|
dockable?: boolean, // show an icon in the dock bar
|
|
171
170
|
close?: boolean, // show the close button
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
171
|
+
modal?: boolean, // show a full-screen overlay that blocks pointer events beneath
|
|
172
|
+
}
|
|
175
173
|
```
|
|
176
174
|
|
|
177
175
|
If `top/left/right/bottom` are all `0` (or unset) the popup is auto-centered.
|
|
178
176
|
Pass `center: true` to force centering regardless of the position props.
|
|
179
177
|
|
|
180
|
-
> **`
|
|
178
|
+
> **`modal`** injects a full-viewport overlay (`popup_modal_<id>`)
|
|
181
179
|
> that intercepts every pointer event - the page underneath becomes unclickable
|
|
182
|
-
> until the popup closes.
|
|
180
|
+
> until the popup closes.
|
|
183
181
|
|
|
184
182
|
> **Duplicate id** - opening a popup whose `id` already exists brings that window
|
|
185
183
|
> to the front and refreshes its `body`/`buttons` instead of doing nothing.
|
|
@@ -313,7 +311,8 @@ layerpro.popup.index({ id: "myModal" });
|
|
|
313
311
|
| `layerpro.popup.store(element)` | Store a reference (placeholder/extensibility) |
|
|
314
312
|
| `layerpro.popup.cleanupEvents(id)` | Remove dock/button/esc listeners |
|
|
315
313
|
| `layerpro.popup.unmount(id)` | Unmount the React root (memory cleanup) |
|
|
316
|
-
| `layerpro.
|
|
314
|
+
| `layerpro.config(opts)` | Runtime config. Supports `{ nonce: string }` for CSP; sets `window.__layerproNonce`. Call before importing LayerPro for the nonce to be present at CSS injection time |
|
|
315
|
+
| `layerpro.installGlobals()` | Explicitly install global `alert`/`confirm`/`prompt`/`message` overrides (opt-in in 4.0) |
|
|
317
316
|
|
|
318
317
|
---
|
|
319
318
|
|
|
@@ -340,12 +339,12 @@ properties, so theming needs no `!important` and no `[class^=popup_…]` selecto
|
|
|
340
339
|
| `--window-border-radius` | popup border radius |
|
|
341
340
|
| `--internal-background` | body wrapper |
|
|
342
341
|
| `--body-color` | body text color |
|
|
343
|
-
| `--
|
|
342
|
+
| `--modal-background` | modal overlay |
|
|
344
343
|
| `--popup-z-index` (in root.scss) | base z-index for the stack |
|
|
345
344
|
|
|
346
345
|
Stable class names (`.popup_bar`, `.popup_window`, `.popup_overflow`,
|
|
347
346
|
`.popup_internal`, `.popup_body`, `.popup_drag`, `.popup_icon`, `.popup_option`,
|
|
348
|
-
`.
|
|
347
|
+
`.popup_modal`) are emitted alongside the per-id classes so themes can target
|
|
349
348
|
elements without attribute selectors.
|
|
350
349
|
|
|
351
350
|
---
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "layerpro",
|
|
3
3
|
"codeName": "layerpro",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0",
|
|
5
5
|
"description": "The real custom modals, alert, confirm, prompt... for your browser",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"module": "./index.js",
|
|
@@ -18,6 +18,11 @@
|
|
|
18
18
|
"require": "./react.cjs",
|
|
19
19
|
"types": "./react.d.ts"
|
|
20
20
|
},
|
|
21
|
+
"./global": {
|
|
22
|
+
"import": "./global.js",
|
|
23
|
+
"require": "./global.cjs",
|
|
24
|
+
"types": "./global.d.ts"
|
|
25
|
+
},
|
|
21
26
|
"./style.css": "./index.css",
|
|
22
27
|
"./types/*": "./types/*"
|
|
23
28
|
},
|
|
@@ -69,7 +74,11 @@
|
|
|
69
74
|
"react.cjs",
|
|
70
75
|
"react.d.ts",
|
|
71
76
|
"react.js",
|
|
77
|
+
"global.cjs",
|
|
78
|
+
"global.d.ts",
|
|
79
|
+
"global.js",
|
|
72
80
|
"README.md",
|
|
81
|
+
"SECURITY-HARDENING.md",
|
|
73
82
|
"SECURITY.md"
|
|
74
83
|
],
|
|
75
84
|
"peerDependencies": {
|
|
@@ -81,9 +90,6 @@
|
|
|
81
90
|
"url": "https://dario.passariello.ca/",
|
|
82
91
|
"email": "dariopassariello@gmail.com"
|
|
83
92
|
},
|
|
84
|
-
"resolutions": {
|
|
85
|
-
"esbuild": "^0.25.0"
|
|
86
|
-
},
|
|
87
93
|
"overrides": {
|
|
88
94
|
"esbuild": "^0.28.2"
|
|
89
95
|
},
|
package/types/layerpro.d.ts
CHANGED
|
@@ -1,143 +1,134 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
layerpro: _layerpro
|
|
136
|
-
popup: _layerpro['popup']
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
declare var layerpro: _layerpro
|
|
140
|
-
type layerpro = _layerpro
|
|
141
|
-
|
|
142
|
-
declare var popup: _layerpro['popup']
|
|
143
|
-
type popup = _layerpro['popup']
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* LayerPro - the real custom modals for your browser.
|
|
5
|
+
*
|
|
6
|
+
* In 4.0, importing `layerpro` no longer overrides `window.alert` /
|
|
7
|
+
* `window.confirm` / `window.prompt` / `window.message`. To opt in to the
|
|
8
|
+
* global overrides, import the `layerpro/global` entrypoint instead.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
interface LayerButtonConfig {
|
|
12
|
+
text: string
|
|
13
|
+
cb?: () => void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface LayerButtonsConfig {
|
|
17
|
+
confirm?: LayerButtonConfig
|
|
18
|
+
cancel?: LayerButtonConfig
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface GenLayerProps {
|
|
22
|
+
id: string | number
|
|
23
|
+
body?: React.ReactElement | string | HTMLElement
|
|
24
|
+
name?: string
|
|
25
|
+
style?: Record<string, string | number>
|
|
26
|
+
class?: string
|
|
27
|
+
icon?: string
|
|
28
|
+
|
|
29
|
+
buttons?: LayerButtonsConfig
|
|
30
|
+
|
|
31
|
+
top?: number | string
|
|
32
|
+
left?: number | string
|
|
33
|
+
right?: number | string
|
|
34
|
+
bottom?: number | string
|
|
35
|
+
|
|
36
|
+
width?: number | string
|
|
37
|
+
height?: number | string
|
|
38
|
+
|
|
39
|
+
minWidth?: number
|
|
40
|
+
minHeight?: number
|
|
41
|
+
maxWidth?: number
|
|
42
|
+
maxHeight?: number
|
|
43
|
+
|
|
44
|
+
fadeIn?: number
|
|
45
|
+
fadeOut?: number
|
|
46
|
+
timer?: number
|
|
47
|
+
|
|
48
|
+
maximize?: boolean
|
|
49
|
+
isMaximize?: boolean
|
|
50
|
+
dockable?: boolean
|
|
51
|
+
movable?: boolean
|
|
52
|
+
|
|
53
|
+
resizable?: boolean
|
|
54
|
+
close?: boolean
|
|
55
|
+
/** Modal overlay - intercepts pointer events on the underlying page. */
|
|
56
|
+
modal?: boolean
|
|
57
|
+
iconize?: boolean
|
|
58
|
+
center?: boolean
|
|
59
|
+
|
|
60
|
+
source?: string
|
|
61
|
+
store?: unknown
|
|
62
|
+
inheritContext?: boolean
|
|
63
|
+
resilient?: boolean
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Interface for the layerpro object
|
|
68
|
+
*/
|
|
69
|
+
interface _layerpro {
|
|
70
|
+
|
|
71
|
+
/** Optional CSP nonce. Set via `layerpro.config({ nonce })` before importing
|
|
72
|
+
* the CSS-in-JS bundle so the injected `<style>` element passes strict CSP.
|
|
73
|
+
* If unset, the nonce is auto-detected from existing `<style>`/`<script>`
|
|
74
|
+
* elements on the page. */
|
|
75
|
+
nonce?: string
|
|
76
|
+
|
|
77
|
+
/** Runtime configuration. Currently supports `{ nonce: string }` for CSP. */
|
|
78
|
+
config: (opts: { nonce?: string }) => void
|
|
79
|
+
|
|
80
|
+
/** Open a LayerPro alert. Returns a Promise that resolves when the popup closes. */
|
|
81
|
+
readonly alert: (txt: string) => Promise<void>
|
|
82
|
+
/** Open a LayerPro prompt. Returns a Promise that resolves to the input string. */
|
|
83
|
+
readonly prompt: (txt: string, defaultValue?: string) => Promise<string>
|
|
84
|
+
/** Open a LayerPro message popup. Returns a Promise that resolves when it closes. */
|
|
85
|
+
readonly message: (txt: string) => Promise<void>
|
|
86
|
+
/** Open a LayerPro confirm. Returns a Promise that resolves to a boolean. */
|
|
87
|
+
readonly confirm: (txt: string) => Promise<boolean>
|
|
88
|
+
readonly credits: (props: { name: string, version: string, description: string, license: string, author: { name: string, email: string } }) => void
|
|
89
|
+
|
|
90
|
+
setProps: (obj: Record<string, unknown>, options?: { enumerable?: boolean, writable?: boolean, configurable?: boolean }) => void
|
|
91
|
+
|
|
92
|
+
/** Opt-in to override the browser's native `alert`/`confirm`/`prompt`/`message`
|
|
93
|
+
* globals with LayerPro's Promise-based versions. Call this explicitly after
|
|
94
|
+
* importing LayerPro - the default entry does **not** auto-override in 4.0.
|
|
95
|
+
* Alternatively, use `import 'layerpro/global'`. */
|
|
96
|
+
readonly installGlobals: () => void
|
|
97
|
+
|
|
98
|
+
readonly popup: {
|
|
99
|
+
/** Open a modal; returns a Promise that resolves with the props when the popup closes. */
|
|
100
|
+
open: (props: GenLayerProps) => Promise<GenLayerProps>
|
|
101
|
+
center: (id: string | number | GenLayerProps, offset?: number) => void
|
|
102
|
+
maximize: (props: GenLayerProps) => void
|
|
103
|
+
iconize: (id: string | number | GenLayerProps) => void
|
|
104
|
+
movable: (props: GenLayerProps) => void
|
|
105
|
+
resizable: (props: GenLayerProps) => void
|
|
106
|
+
store: (element: unknown) => void
|
|
107
|
+
index: (id: string | number | GenLayerProps) => void
|
|
108
|
+
close: (id: string | number | GenLayerProps | null | undefined) => void
|
|
109
|
+
unmount: (id: string) => void
|
|
110
|
+
cleanupEvents: (id: string) => void
|
|
111
|
+
abortSource: (id: string) => void
|
|
112
|
+
/** @internal - managed internally for stacking order; do not call. */
|
|
113
|
+
zIndex: (props?: GenLayerProps) => number
|
|
114
|
+
useReactAdapter?: (props: GenLayerProps, container: HTMLElement) => void
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* In 4.0, `layerpro` and `popup` are declared on `Window` but the native
|
|
121
|
+
* `alert`/`confirm`/`prompt`/`message` globals are NOT overridden by the
|
|
122
|
+
* default entry. Import `layerpro/global` to override them with Promise-based
|
|
123
|
+
* versions.
|
|
124
|
+
*/
|
|
125
|
+
interface Window {
|
|
126
|
+
layerpro: _layerpro
|
|
127
|
+
popup: _layerpro['popup']
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
declare var layerpro: _layerpro
|
|
131
|
+
type layerpro = _layerpro
|
|
132
|
+
|
|
133
|
+
declare var popup: _layerpro['popup']
|
|
134
|
+
type popup = _layerpro['popup']
|