layerpro 3.4.0 → 4.0.1

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
@@ -1,9 +1,13 @@
1
1
  # LayerPro
2
2
 
3
- > Dependency-free custom modals (alert, confirm, prompt, message) and advanced
4
- > popups for the browser. Vanilla DOM (no jQuery); React/react-dom are external
5
- > and used only to render the modal body. Dockable, draggable, resizable,
6
- > maximizable (pure CSS), with an OS-style taskbar.
3
+ > Browser window system: OS-style windows (draggable, resizable, maximizable,
4
+ > dockable) that host any content, including React components. Also provides
5
+ > Promise-based custom modals (alert, confirm, prompt, message) as a drop-in
6
+ > replacement for the browser's native ones. Vanilla DOM (no jQuery);
7
+ > React/react-dom are external and used only to render the modal body.
8
+ > Dockable, draggable, resizable, maximizable (pure CSS), with an OS-style
9
+ > taskbar. Fully themeable via CSS custom properties or the `layerpro` cascade
10
+ > layer - see "Overriding the CSS" in the README.
7
11
 
8
12
  ## Source
9
13
 
@@ -11,11 +15,13 @@
11
15
  - [core/dom.ts](core/dom.ts): jQuery-free chainable DOM helper (`LpEl`, `lp`, `lpAll`, `lpCreate`, `lpDoc`, `lpWin`) - the replacement for jQuery.
12
16
  - [core/properties.ts](core/properties.ts): The `popup` object - `open`, `close`, `center`, `maximize`, `iconize`, `index`, `zIndex`, `movable`, `resizable`, `cleanupEvents`, `unmount`.
13
17
  - [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.
18
+ - [core/accessibility.ts](core/accessibility.ts): ARIA attributes, focus save/restore, Tab focus trap.
19
+ - [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
20
  - [core/mode.ts](core/mode.ts): Close popups on orientation/size mode switch.
16
21
  - [core/mobile.ts](core/mobile.ts): Unified pointer/mouse/touch events (`getPointerDown`/`getPointerMove`/`getPointerUp`).
17
22
  - [core/window.ts](core/window.ts): Window-level helpers (scroll, size).
18
23
  - [core/credits.ts](core/credits.ts): Credits overlay helper.
24
+ - [core/version.ts](core/version.ts): `layerpro.version()` - reads the current version from `app.json`.
19
25
  - [core/namespace.ts](core/namespace.ts): Global namespace setup.
20
26
 
21
27
  ## Types
@@ -27,6 +33,7 @@
27
33
  - [docs/README.md](docs/README.md): Project README (features, install, quick start).
28
34
  - [docs/markdown/GUIDE.md](docs/markdown/GUIDE.md): Example-driven usage guide (modals, popups, dock, maximize, resize, React body, API).
29
35
  - [docs/llms.txt](docs/llms.txt): This file.
36
+ - [docs/SECURITY-HARDENING.md](docs/SECURITY-HARDENING.md): Security reference (CSP, XSS, SSRF, global overrides, accessibility).
30
37
 
31
38
  ## Build & Config
32
39
 
package/markdown/GUIDE.md CHANGED
@@ -1,7 +1,10 @@
1
1
  # LayerPro Guide
2
2
 
3
- > A practical, example-driven guide to LayerPro - the real custom modals
4
- > (alert, confirm, prompt, message) and advanced popups for the browser.
3
+ > A practical, example-driven guide to LayerPro - a browser window system that
4
+ > generates OS-style windows (draggable, resizable, maximizable, dockable) able
5
+ > to host any content, including React components, and that also provides
6
+ > Promise-based custom modals (alert, confirm, prompt, message) as a drop-in
7
+ > replacement for the browser's native ones.
5
8
 
6
9
  LayerPro is **dependency-free**: it no longer uses jQuery. All DOM work is done
7
10
  with small, chainable vanilla helpers. React and react-dom are the only
@@ -16,14 +19,16 @@ body when you pass a React element.
16
19
  2. [Quick Start](#quick-start)
17
20
  3. [Basic Modals](#basic-modals)
18
21
  4. [Custom Popups](#custom-popups)
19
- 5. [Options Reference](#options-reference)
20
- 6. [Dock & Taskbar](#dock--taskbar)
21
- 7. [Maximize & Minimize](#maximize--minimize)
22
- 8. [Dragging & Resizing](#dragging--resizing)
23
- 9. [React Body](#react-body)
24
- 10. [Selection & z-index](#selection--z-index)
25
- 11. [API Methods](#api-methods)
26
- 12. [Notes & Migration](#notes--migration)
22
+ 5. [OS-style Windows](#os-style-windows)
23
+ 6. [Options Reference](#options-reference)
24
+ 7. [Dock & Taskbar](#dock--taskbar)
25
+ 8. [Maximize & Minimize](#maximize--minimize)
26
+ 9. [Dragging & Resizing](#dragging--resizing)
27
+ 10. [React Body](#react-body)
28
+ 11. [Selection & z-index](#selection--z-index)
29
+ 12. [API Methods](#api-methods)
30
+ 13. [Styling & z-index](#styling--z-index)
31
+ 14. [Notes & Migration](#notes--migration)
27
32
 
28
33
  ---
29
34
 
@@ -53,15 +58,14 @@ import "layerpro";
53
58
  That single import is enough - `window.layerpro` becomes available and the
54
59
  global `alert`/`confirm`/`prompt` are replaced, and a `message` global is added.
55
60
 
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:
61
+ > **⚠️ Global override note:** in 4.0, `import 'layerpro'` does **not** override
62
+ > `window.alert`/`confirm`/`prompt`/`message`. The library methods
63
+ > (`layerpro.alert`, `layerpro.confirm`, etc.) return Promises. To override the
64
+ > browser globals with Promise-based versions, import the explicit entry point:
61
65
  >
62
66
  > ```javascript
63
- > import "layerpro";
64
- > layerpro.noGlobals(); // restores native alert/confirm/prompt, drops `message`
67
+ > import "layerpro/global"; // opt-in to global overrides
68
+ > await confirm("Sure?"); // Promise<boolean>
65
69
  > ```
66
70
 
67
71
  ---
@@ -130,6 +134,55 @@ layerpro.popup.open({
130
134
 
131
135
  ---
132
136
 
137
+ ## OS-style Windows
138
+
139
+ A popup is not limited to a modal dialog. With `movable`, `resizable`,
140
+ `maximize`, `iconize` and `dockable` enabled it becomes a real OS-style
141
+ window: draggable by its title bar, resizable from the edges, maximizable,
142
+ minimizable into the dock, and stackable with the other windows on the page.
143
+
144
+ ```javascript
145
+ layerpro.popup.open({
146
+ id: "dashboard",
147
+ name: "Dashboard",
148
+ icon: "&#128202;",
149
+ body: "<h2>Live metrics</h2><p>Anything you want inside.</p>",
150
+ width: 640,
151
+ height: 420,
152
+ movable: true,
153
+ resizable: true,
154
+ maximize: true,
155
+ iconize: true,
156
+ dockable: true,
157
+ close: true
158
+ });
159
+ ```
160
+
161
+ With a React component inside, this becomes a real application window rendered
162
+ in the page with native-looking chrome:
163
+
164
+ ```jsx
165
+ layerpro.popup.open({
166
+ id: "settingsWindow",
167
+ name: "Settings",
168
+ icon: "&#9881;",
169
+ body: <SettingsPanel />,
170
+ width: 720,
171
+ height: 480,
172
+ movable: true,
173
+ resizable: true,
174
+ maximize: true,
175
+ iconize: true,
176
+ dockable: true,
177
+ close: true
178
+ });
179
+ ```
180
+
181
+ > `modal: true` is what turns a window into a blocking dialog. Leave it off for
182
+ > windows the user should be able to move around while working on the page.
183
+
184
+ ---
185
+
133
186
  ## Options Reference
134
187
 
135
188
  ```typescript
@@ -169,17 +222,16 @@ layerpro.popup.open({
169
222
  iconize?: boolean, // allow minimize to dock
170
223
  dockable?: boolean, // show an icon in the dock bar
171
224
  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
- }
225
+ modal?: boolean, // show a full-screen overlay that blocks pointer events beneath
226
+ }
175
227
  ```
176
228
 
177
229
  If `top/left/right/bottom` are all `0` (or unset) the popup is auto-centered.
178
230
  Pass `center: true` to force centering regardless of the position props.
179
231
 
180
- > **`raised` / `modal`** injects a full-viewport overlay (`popup_raised_<id>`)
232
+ > **`modal`** injects a full-viewport overlay (`popup_modal_<id>`)
181
233
  > that intercepts every pointer event - the page underneath becomes unclickable
182
- > until the popup closes. This is modal behavior; both names are accepted.
234
+ > until the popup closes.
183
235
 
184
236
  > **Duplicate id** - opening a popup whose `id` already exists brings that window
185
237
  > to the front and refreshes its `body`/`buttons` instead of doing nothing.
@@ -313,7 +365,8 @@ layerpro.popup.index({ id: "myModal" });
313
365
  | `layerpro.popup.store(element)` | Store a reference (placeholder/extensibility) |
314
366
  | `layerpro.popup.cleanupEvents(id)` | Remove dock/button/esc listeners |
315
367
  | `layerpro.popup.unmount(id)` | Unmount the React root (memory cleanup) |
316
- | `layerpro.noGlobals()` | Restore native `alert`/`confirm`/`prompt`; remove `message` |
368
+ | `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 |
369
+ | `layerpro.installGlobals()` | Explicitly install global `alert`/`confirm`/`prompt`/`message` overrides (opt-in in 4.0) |
317
370
 
318
371
  ---
319
372
 
@@ -340,14 +393,110 @@ properties, so theming needs no `!important` and no `[class^=popup_…]` selecto
340
393
  | `--window-border-radius` | popup border radius |
341
394
  | `--internal-background` | body wrapper |
342
395
  | `--body-color` | body text color |
343
- | `--raised-background` | modal overlay |
396
+ | `--modal-background` | modal overlay |
344
397
  | `--popup-z-index` (in root.scss) | base z-index for the stack |
345
398
 
346
399
  Stable class names (`.popup_bar`, `.popup_window`, `.popup_overflow`,
347
400
  `.popup_internal`, `.popup_body`, `.popup_drag`, `.popup_icon`, `.popup_option`,
348
- `.popup_raised`) are emitted alongside the per-id classes so themes can target
401
+ `.popup_modal`) are emitted alongside the per-id classes so themes can target
349
402
  elements without attribute selectors.
350
403
 
404
+ ### Overriding the CSS
405
+
406
+ LayerPro never writes a plain inline style: every declaration lives in the
407
+ stylesheet and is driven by a **class** (the state) or by a **CSS custom
408
+ property** (the value). That means any part of a window can be restyled with
409
+ a plain CSS rule - nothing needs `!important` to win over an inline style.
410
+
411
+ There are three ways to restyle LayerPro, from the most recommended to the most
412
+ surgical.
413
+
414
+ **1. CSS custom properties (recommended).** Every visual detail is driven by a
415
+ variable on `:root`, so theming needs no selectors and no `!important`:
416
+
417
+ ```css
418
+ :root {
419
+ --bar-background: #1f2937;
420
+ --bar-selected-background: #2563eb;
421
+ --bar-color: #f9fafb;
422
+ --window-background: #111827;
423
+ --window-border-radius: 4px;
424
+ --internal-background: #0b1220;
425
+ --body-color: #e5e7eb;
426
+ --button-background-color: #2563eb;
427
+ --button-color: #ffffff;
428
+ }
429
+ ```
430
+
431
+ Variables can also be scoped per popup, because every window lives inside
432
+ `#popup`:
433
+
434
+ ```css
435
+ #popup .popup_window_myDarkPopup {
436
+ --window-background: #000;
437
+ --bar-background: #000;
438
+ }
439
+ ```
440
+
441
+ **2. Target the generated classes.** Each element carries a stable class alias
442
+ next to its id-suffixed class:
443
+
444
+ ```css
445
+ #popup .popup_window { border-radius: 0; }
446
+ #popup .buttons button { background: #2563eb; }
447
+ #popup .popup_option .close:hover { background: #dc2626; }
448
+ #popup_dock { background: #111827; }
449
+ ```
450
+
451
+ The visual **states** are classes too, so they can be restyled like any other
452
+ element:
453
+
454
+ | Class | Applied when |
455
+ |-------|--------------|
456
+ | `.popup_maximized` | the window is maximized |
457
+ | `.popup_iconized` | the window is minimized to the dock |
458
+ | `.popup_dimmed` | another window has the focus |
459
+ | `.popup_content_hidden` | another window has the focus |
460
+ | `.popup_content_visible` | the window has the focus |
461
+ | `.lp_hidden` | the element is hidden |
462
+ | `.lp_fade_in` / `.lp_fade_out` | during a fade |
463
+ | `.lp_no_pointer` | while dragging/resizing |
464
+ | `.lp_no_touch` | on the drag/resize handles |
465
+ | `.lp_no_transition` | while resizing |
466
+
467
+ ```css
468
+ #popup .popup_maximized { inset: 0; bottom: 0; }
469
+ #popup .popup_dimmed { opacity: .8; }
470
+ ```
471
+
472
+ The geometry of a window is carried by custom properties, so it can be
473
+ overridden as well: `--lp-top`, `--lp-left`, `--lp-right`, `--lp-bottom`,
474
+ `--lp-width`, `--lp-height`, `--lp-min-width`, `--lp-min-height`,
475
+ `--lp-max-width`, `--lp-max-height`, `--lp-z-index`.
476
+
477
+ ```css
478
+ #popup .popup_overflow { --lp-left: 50%; --lp-top: 100px; }
479
+ ```
480
+
481
+ **3. Cascade layers (full control).** All LayerPro styles live inside the CSS
482
+ cascade layer `layerpro`. Unlayered host rules always win, so a host stylesheet
483
+ can restyle the popups without `!important`:
484
+
485
+ ```css
486
+ #popup { border-radius: 4px; }
487
+ ```
488
+
489
+ If the host declares its own layer, it must be declared **before** `layerpro`,
490
+ otherwise it loses:
491
+
492
+ ```css
493
+ @layer app, layerpro;
494
+ ```
495
+
496
+ > Do **not** rely on `!important` to override LayerPro: LayerPro's `!important`
497
+ > rules live inside a layer and are stronger than unlayered host `!important`
498
+ > rules. Use plain rules or a host layer declared before `layerpro`.
499
+
351
500
  ---
352
501
 
353
502
  ## Notes & Migration
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.1",
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,153 @@
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
+ * Open the layer inside a real browser window (`window.open`) instead of
67
+ * the in-page overlay. The window keeps the layer information: name, icon,
68
+ * dimensions, position, body and buttons.
69
+ */
70
+ native?: boolean
71
+ /**
72
+ * Save the position and the size of the window and restore them on the
73
+ * next open with the same id (stored in `localStorage`).
74
+ */
75
+ persist?: boolean
76
+ /**
77
+ * Close the native window when the page that opened it is closed.
78
+ * A reload/refresh of the opener does NOT close the native window.
79
+ */
80
+ closeWithOpener?: boolean
81
+ }
82
+
83
+ /**
84
+ * Interface for the layerpro object
85
+ */
86
+ interface _layerpro {
87
+
88
+ /** Optional CSP nonce. Set via `layerpro.config({ nonce })` before importing
89
+ * the CSS-in-JS bundle so the injected `<style>` element passes strict CSP.
90
+ * If unset, the nonce is auto-detected from existing `<style>`/`<script>`
91
+ * elements on the page. */
92
+ nonce?: string
93
+
94
+ /** Runtime configuration. Currently supports `{ nonce: string }` for CSP. */
95
+ config: (opts: { nonce?: string }) => void
96
+
97
+ /** Open a LayerPro alert. Returns a Promise that resolves when the popup closes. */
98
+ readonly alert: (txt: string) => Promise<void>
99
+ /** Open a LayerPro prompt. Returns a Promise that resolves to the input string. */
100
+ readonly prompt: (txt: string, defaultValue?: string) => Promise<string>
101
+ /** Open a LayerPro message popup. Returns a Promise that resolves when it closes. */
102
+ readonly message: (txt: string) => Promise<void>
103
+ /** Open a LayerPro confirm. Returns a Promise that resolves to a boolean. */
104
+ readonly confirm: (txt: string) => Promise<boolean>
105
+ readonly credits: (props: { name: string, version: string, description: string, license: string, author: { name: string, email: string } }) => void
106
+
107
+ setProps: (obj: Record<string, unknown>, options?: { enumerable?: boolean, writable?: boolean, configurable?: boolean }) => void
108
+
109
+ /** Opt-in to override the browser's native `alert`/`confirm`/`prompt`/`message`
110
+ * globals with LayerPro's Promise-based versions. Call this explicitly after
111
+ * importing LayerPro - the default entry does **not** auto-override in 4.0.
112
+ * Alternatively, use `import 'layerpro/global'`. */
113
+ readonly installGlobals: () => void
114
+
115
+ readonly popup: {
116
+ /** Open a modal; returns a Promise that resolves with the props when the popup closes. */
117
+ open: (props: GenLayerProps) => Promise<GenLayerProps>
118
+ center: (id: string | number | GenLayerProps, offset?: number) => void
119
+ maximize: (props: GenLayerProps) => void
120
+ iconize: (id: string | number | GenLayerProps) => void
121
+ movable: (props: GenLayerProps) => void
122
+ resizable: (props: GenLayerProps) => void
123
+ store: (element: unknown) => void
124
+ index: (id: string | number | GenLayerProps) => void
125
+ close: (id: string | number | GenLayerProps | null | undefined) => void
126
+ unmount: (id: string) => void
127
+ /** Remove a popup and its DOM synchronously. */
128
+ destroy: (id: string) => void
129
+ cleanupEvents: (id: string) => void
130
+ abortSource: (id: string) => void
131
+ /** @internal - managed internally for stacking order; do not call. */
132
+ zIndex: (props?: GenLayerProps) => number
133
+ useReactAdapter?: (props: GenLayerProps, container: HTMLElement) => void
134
+ }
135
+
136
+ }
137
+
138
+ /**
139
+ * In 4.0, `layerpro` and `popup` are declared on `Window` but the native
140
+ * `alert`/`confirm`/`prompt`/`message` globals are NOT overridden by the
141
+ * default entry. Import `layerpro/global` to override them with Promise-based
142
+ * versions.
143
+ */
144
+ interface Window {
145
+ layerpro: _layerpro
146
+ popup: _layerpro['popup']
147
+ }
148
+
149
+ declare var layerpro: _layerpro
150
+ type layerpro = _layerpro
151
+
152
+ declare var popup: _layerpro['popup']
153
+ type popup = _layerpro['popup']