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/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/message.ts](core/message.ts): `alert`/`confirm`/`message`/`prompt` implementations; overrides `window.alert`/`confirm`/`prompt` (callback-based, NOT synchronous) and provides `layerpro.noGlobals()` to restore natives.
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 contract:** the overridden `confirm()` no longer returns a
57
- > `boolean` and `prompt()` no longer returns a `string` - they are callback-based
58
- > and return `undefined`. If your codebase (or a third-party dependency) relies on
59
- > the native synchronous return values, call `layerpro.noGlobals()` right after
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
- > layerpro.noGlobals(); // restores native alert/confirm/prompt, drops `message`
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
- raised?: boolean, // alias: modal - show a full-screen overlay that
173
- modal?: boolean, // blocks pointer events to the page underneath
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
- > **`raised` / `modal`** injects a full-viewport overlay (`popup_raised_<id>`)
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. This is modal behavior; both names are accepted.
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.noGlobals()` | Restore native `alert`/`confirm`/`prompt`; remove `message` |
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
- | `--raised-background` | modal overlay |
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
- `.popup_raised`) are emitted alongside the per-id classes so themes can target
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": "3.4.0",
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
  },
@@ -1,143 +1,134 @@
1
- /// <reference types="react" />
2
-
3
- /** Generate custom alert using alert([text]) */
4
- declare function alert(f1?: string): void
5
-
6
- /** Generate custom confirm using confirm([text],[callback for YES],[optional callback for NO])
7
- * WARNING: This overrides the native confirm(). The return value is NOT a usable
8
- * boolean - callbacks are invoked asynchronously instead. Never rely on the
9
- * return value; use the yes/no callbacks. */
10
- declare function confirm(message: string, func1: (yes: boolean) => void, func2?: (no: boolean) => void): void
11
-
12
- /** Generate custom message using message([text],[callback]) and option callback */
13
- declare function message(f1?: string, func1?: () => void): void
14
-
15
- /** Generate custom prompt using prompt([text],[callback]) and option callback
16
- * WARNING: This overrides the native prompt(). The return value is NOT a usable
17
- * string - use the callback to receive the input. */
18
- declare function prompt(f1?: string, func1?: (input: string) => void): void
19
-
20
- ///
21
-
22
- interface LayerButtonConfig {
23
- text: string
24
- cb?: () => void
25
- }
26
-
27
- interface LayerButtonsConfig {
28
- confirm?: LayerButtonConfig
29
- cancel?: LayerButtonConfig
30
- }
31
-
32
- interface GenLayerProps {
33
- id: string | number
34
- body?: React.ReactElement | string | HTMLElement
35
- name?: string
36
- style?: Record<string, string | number>
37
- class?: string
38
- icon?: string
39
-
40
- buttons?: LayerButtonsConfig
41
-
42
- top?: number | string
43
- left?: number | string
44
- right?: number | string
45
- bottom?: number | string
46
-
47
- width?: number | string
48
- height?: number | string
49
-
50
- minWidth?: number
51
- minHeight?: number
52
- maxWidth?: number
53
- maxHeight?: number
54
-
55
- fadeIn?: number
56
- fadeOut?: number
57
- timer?: number
58
-
59
- maximize?: boolean
60
- isMaximize?: boolean
61
- dockable?: boolean
62
- movable?: boolean
63
-
64
- resizable?: boolean
65
- close?: boolean
66
- raised?: boolean
67
- modal?: boolean
68
- iconize?: boolean
69
- center?: boolean
70
-
71
- source?: string
72
- store?: unknown
73
- inheritContext?: boolean
74
- resilient?: boolean
75
- }
76
-
77
- /**
78
- * Interface for the layerpro object
79
- */
80
- interface _layerpro {
81
-
82
- /** Optional CSP nonce. Set via `layerpro.config({ nonce })` before importing
83
- * the CSS-in-JS bundle so the injected `<style>` element passes strict CSP.
84
- * If unset, the nonce is auto-detected from existing `<style>`/`<script>`
85
- * elements on the page. */
86
- nonce?: string
87
-
88
- /** Runtime configuration. Currently supports `{ nonce: string }` for CSP. */
89
- config: (opts: { nonce?: string }) => void
90
-
91
- readonly alert: (txt: string) => void
92
- readonly prompt: (txt: string, callback: (input: string) => void) => void
93
- readonly message: (txt: string, callback: () => void) => void
94
- readonly confirm: (txt: string, yesCallback: () => void, noCallback?: () => void) => void
95
- readonly credits: (props: { name: string, version: string, description: string, license: string, author: { name: string, email: string } }) => void
96
-
97
- setProps: (obj: Record<string, unknown>, options?: { enumerable?: boolean, writable?: boolean }) => void
98
-
99
- /** Remove the global alert/confirm/prompt/message overrides and restore
100
- * the native browser implementations. Call this right after importing
101
- * LayerPro if your codebase depends on synchronous native globals. */
102
- readonly noGlobals: () => void
103
-
104
- /** Opt-in to override the browser's native alert/confirm/prompt/message
105
- * globals with LayerPro's callback-based versions. This is opt-in so
106
- * libraries embedded in other applications do not silently change
107
- * global behavior. */
108
- readonly installGlobals: () => void
109
-
110
- readonly popup: {
111
- open: (props: GenLayerProps) => GenLayerProps
112
- center: (id: string | number | GenLayerProps, offset?: number) => void
113
- maximize: (props: GenLayerProps) => void
114
- iconize: (id: string | number | GenLayerProps) => void
115
- movable: (props: GenLayerProps) => void
116
- resizable: (props: GenLayerProps) => void
117
- store: (element: unknown) => void
118
- index: (id: string | number | GenLayerProps) => void
119
- zIndex: (props?: GenLayerProps) => number
120
- close: (id: string | number | GenLayerProps | null | undefined) => void
121
- unmount: (id: string) => void
122
- cleanupEvents: (id: string) => void
123
- abortSource: (id: string) => void
124
- useReactAdapter?: (props: GenLayerProps, container: HTMLElement) => void
125
- }
126
-
127
- }
128
-
129
- /**
130
- * LayerPro overrides the native alert/confirm/prompt globals and adds a
131
- * `message` global. They are callback-based and do NOT return native values.
132
- * Call `layerpro.noGlobals()` to restore the synchronous natives.
133
- */
134
- interface Window {
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']