layerpro 3.1.1 → 3.1.5

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/package.json CHANGED
@@ -1,12 +1,25 @@
1
1
  {
2
2
  "name": "layerpro",
3
3
  "codeName": "layerpro",
4
- "version": "3.1.1",
4
+ "version": "3.1.5",
5
5
  "description": "The real custom modals, alert, confirm, prompt... for your browser",
6
6
  "main": "./index.cjs",
7
- "browser": "./index.js",
7
+ "module": "./index.js",
8
+ "browser": "./dist/index.js",
8
9
  "types": "./index.d.ts",
9
- "typing": "./types/*",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./index.js",
13
+ "require": "./index.cjs",
14
+ "types": "./index.d.ts"
15
+ },
16
+ "./react": {
17
+ "import": "./react.js",
18
+ "require": "./react.cjs",
19
+ "types": "./react.d.ts"
20
+ },
21
+ "./types/*": "./types/*"
22
+ },
10
23
  "license": "MIT",
11
24
  "copyright": "Dario Passariello",
12
25
  "author": "Dario Passariello",
@@ -41,21 +54,30 @@
41
54
  "node": ">=18.0.0"
42
55
  },
43
56
  "files": [
44
- "**/*"
57
+ "markdown/**/*",
58
+ "types/**/*",
59
+ "COPYRIGHT.md",
60
+ "FUNDING.yml",
61
+ "index.cjs",
62
+ "index.css",
63
+ "index.d.ts",
64
+ "index.js",
65
+ "LICENSE.md",
66
+ "llms.txt",
67
+ "package.json",
68
+ "react.cjs",
69
+ "react.js",
70
+ "README.md",
71
+ "SECURITY.md"
45
72
  ],
73
+ "peerDependencies": {
74
+ "react": ">=18",
75
+ "react-dom": ">=18"
76
+ },
46
77
  "support": {
47
78
  "name": "Dario Passariello",
48
79
  "url": "https://dario.passariello.ca/",
49
80
  "email": "dariopassariello@gmail.com"
50
81
  },
51
- "module": "./index.js",
52
- "exports": {
53
- ".": {
54
- "import": "./index.js",
55
- "require": "./index.cjs",
56
- "types": "./index.d.ts"
57
- },
58
- "./types/*": "./types/*"
59
- },
60
82
  "typings": "./index.d.ts"
61
83
  }
package/react.cjs ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ var e = require("react-dom/client"), o = (o, n, r) => {
4
+ const t = String(o.id);
5
+ try {
6
+ if (r) {
7
+ const e = r.get(t);
8
+ if (e) return void e.render(o.body);
9
+ }
10
+ const s = e.createRoot(n);
11
+ s.render(o.body), r && r.set(t, s);
12
+ } catch (e) {
13
+ const o = e instanceof Error ? e.message : String(e);
14
+ o.includes("Invalid hook call") || o.includes("hooks") ? console.error("LayerPro Error: React hooks error detected. This usually happens when:\n1. Multiple copies of React are loaded on the page\n2. The component is called as a function instead of being passed as JSX\n3. React version mismatch between the app and LayerPro\n\nMake sure body is passed as <Component /> not <Component />()") : console.error("Error rendering React component:", e);
15
+ }
16
+ };
17
+
18
+ module.exports = o;
package/react.js ADDED
@@ -0,0 +1,18 @@
1
+ import { createRoot as e } from "react-dom/client";
2
+
3
+ var o = (o, n, r) => {
4
+ const t = String(o.id);
5
+ try {
6
+ if (r) {
7
+ const e = r.get(t);
8
+ if (e) return void e.render(o.body);
9
+ }
10
+ const a = e(n);
11
+ a.render(o.body), r && r.set(t, a);
12
+ } catch (e) {
13
+ const o = e instanceof Error ? e.message : String(e);
14
+ o.includes("Invalid hook call") || o.includes("hooks") ? console.error("LayerPro Error: React hooks error detected. This usually happens when:\n1. Multiple copies of React are loaded on the page\n2. The component is called as a function instead of being passed as JSX\n3. React version mismatch between the app and LayerPro\n\nMake sure body is passed as <Component /> not <Component />()") : console.error("Error rendering React component:", e);
15
+ }
16
+ };
17
+
18
+ export { o as default };
@@ -1,132 +1,132 @@
1
-
2
-
3
-
4
- /// <reference types="react" />
5
-
6
- /** Generate custom alert using alert([text]) */
7
- declare function alert(f1?: string): void
8
-
9
- /** Generate custom confirm using confirm([text],[callback for YES],[optional callback for NO])
10
- * WARNING: This overrides the native confirm(). The return value is NOT a usable
11
- * boolean — callbacks are invoked asynchronously instead. Never rely on the
12
- * return value; use the yes/no callbacks. */
13
- declare function confirm(message: string, func1: (yes: boolean) => void, func2?: (no: boolean) => void): void
14
-
15
- /** Generate custom message using message([text],[callback]) and option callback */
16
- declare function message(f1?: string, func1?: () => void): void
17
-
18
- /** Generate custom prompt using prompt([text],[callback]) and option callback
19
- * WARNING: This overrides the native prompt(). The return value is NOT a usable
20
- * string — use the callback to receive the input. */
21
- declare function prompt(f1?: string, func1?: (input: string) => void): void
22
-
23
- ///
24
-
25
- interface GenLayerProps {
26
-
27
- id: string | number
28
- body?: React.ReactElement | string | HTMLElement
29
- name?: string
30
- style?: any
31
- class?: string
32
- icon?: string
33
-
34
- buttons?: {
35
- confirm?: {
36
- text: string
37
- cb?: () => void
38
- }
39
- cancel?: {
40
- text: string
41
- cb?: () => void
42
- }
43
- }
44
-
45
- top?: number | string
46
- left?: number | string
47
- right?: number | string
48
- bottom?: number | string
49
-
50
- width?: number | string
51
- height?: number | string
52
-
53
- minWidth?: number
54
- minHeight?: number
55
- maxWidth?: number
56
- maxHeight?: number
57
-
58
- fadeIn?: number
59
- fadeOut?: number
60
- timer?: number
61
-
62
- maximize?: boolean
63
- isMaximize?: boolean
64
- dockable?: boolean
65
- movable?: boolean
66
-
67
- resizable?: boolean
68
- close?: boolean
69
- raised?: boolean
70
- modal?: boolean
71
- iconize?: boolean
72
- center?: boolean
73
-
74
- source?: string
75
- store?: any
76
-
77
- }
78
-
79
- /**
80
- * Interface for the layerpro object
81
- */
82
- interface _layerpro {
83
-
84
- [key: string]: any
85
-
86
- readonly alert: (txt: string) => void
87
- readonly prompt: (txt: string, callback: (input: string) => void) => void
88
- readonly message: (txt: string, callback: () => void) => void
89
- readonly confirm: (txt: string, yesCallback: () => void, noCallback?: () => void) => void
90
- readonly credits: (txt: string) => void
91
-
92
- setProps: (obj: Record<string, unknown>, options?: { enumerable?: boolean, writable?: boolean }) => void
93
-
94
- /** Remove the global alert/confirm/prompt/message overrides and restore
95
- * the native browser implementations. Call this right after importing
96
- * LayerPro if your codebase depends on synchronous native globals. */
97
- readonly noGlobals: () => void
98
-
99
- readonly popup: {
100
- open: (props: GenLayerProps) => 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
- zIndex: (props?: GenLayerProps) => number
109
- close: (id: string | number | GenLayerProps) => void
110
- // React root management for memory cleanup
111
- unmount: (id: string) => void
112
- getReactRoot: (id: string) => any
113
- // Event listener cleanup
114
- cleanupEvents: (id: string) => void
115
- }
116
-
117
- }
118
-
119
- /**
120
- * LayerPro overrides the native alert/confirm/prompt globals and adds a
121
- * `message` global. They are callback-based and do NOT return native values.
122
- * Call `layerpro.noGlobals()` to restore the synchronous natives.
123
- */
124
- interface Window {
125
- layerpro: _layerpro
126
- }
127
-
128
- declare var layerpro: _layerpro
129
- type layerpro = _layerpro
130
-
131
- declare var popup: layerpro
132
- type popup = layerpro
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
+ }
74
+
75
+ /**
76
+ * Interface for the layerpro object
77
+ */
78
+ interface _layerpro {
79
+
80
+ readonly alert: (txt: string) => void
81
+ readonly prompt: (txt: string, callback: (input: string) => void) => void
82
+ readonly message: (txt: string, callback: () => void) => void
83
+ readonly confirm: (txt: string, yesCallback: () => void, noCallback?: () => void) => void
84
+ readonly credits: (props: { name: string, version: string, description: string, license: string, author: { name: string, email: string } }) => void
85
+
86
+ setProps: (obj: Record<string, unknown>, options?: { enumerable?: boolean, writable?: boolean }) => void
87
+
88
+ /** Remove the global alert/confirm/prompt/message overrides and restore
89
+ * the native browser implementations. Call this right after importing
90
+ * LayerPro if your codebase depends on synchronous native globals. */
91
+ readonly noGlobals: () => void
92
+
93
+ /** Opt-in to override the browser's native alert/confirm/prompt/message
94
+ * globals with LayerPro's callback-based versions. This is opt-in so
95
+ * libraries embedded in other applications do not silently change
96
+ * global behavior. */
97
+ readonly installGlobals: () => void
98
+
99
+ readonly popup: {
100
+ open: (props: GenLayerProps) => 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
+ zIndex: (props?: GenLayerProps) => number
109
+ close: (id: string | number | GenLayerProps | null | undefined) => void
110
+ unmount: (id: string) => void
111
+ getReactRoots: () => Map<string, { unmount: () => void }> | null
112
+ cleanupEvents: (id: string) => void
113
+ abortSource: (id: string) => void
114
+ useReactAdapter?: (props: GenLayerProps, container: HTMLElement) => void
115
+ }
116
+
117
+ }
118
+
119
+ /**
120
+ * LayerPro overrides the native alert/confirm/prompt globals and adds a
121
+ * `message` global. They are callback-based and do NOT return native values.
122
+ * Call `layerpro.noGlobals()` to restore the synchronous natives.
123
+ */
124
+ interface Window {
125
+ layerpro: _layerpro
126
+ }
127
+
128
+ declare var layerpro: _layerpro
129
+ type layerpro = _layerpro
130
+
131
+ declare var popup: layerpro
132
+ type popup = layerpro