pawajs 2.0.0 → 2.0.2

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/index.d.ts CHANGED
@@ -78,6 +78,52 @@ export interface PawaElement extends HTMLElement {
78
78
  safeEval(context: any, expr: string, error?: string, element?: boolean): any;
79
79
  }
80
80
 
81
+ export interface PawaDev {
82
+ tool: boolean;
83
+ errors: any[];
84
+ totalEffect: number;
85
+ errorState: any;
86
+ components: Set<any>;
87
+ renderCount: number;
88
+ performance: {
89
+ renderTime: number[];
90
+ effectTime: number[];
91
+ componentTime: number[];
92
+ start: number;
93
+ end: number;
94
+ };
95
+ _originalStyles: Map<any, any>;
96
+ listeners: Set<Function>;
97
+ highlightElement(el: HTMLElement): void;
98
+ unhighlightElement(el: HTMLElement): void;
99
+ subscribe(cb: (event: { type: string; data: any }) => void): () => void;
100
+ emit(type: string, data: any): void;
101
+ setError(options?: {
102
+ el?: HTMLElement;
103
+ msg?: string;
104
+ directives?: string;
105
+ stack?: string;
106
+ template?: string;
107
+ warn?: boolean;
108
+ }): void;
109
+ clearErrors(): void;
110
+ getSnapshot(): {
111
+ renderCount: number;
112
+ totalEffect: number;
113
+ performance: any;
114
+ errors: any[];
115
+ componentCount: number;
116
+ };
117
+ logRender(c: any, t: any): void;
118
+ logEffect(e: any, t: any): void;
119
+ logComponent(n: any, t: any): void;
120
+ }
121
+
122
+ declare global {
123
+ var __pawaDev: PawaDev;
124
+ var __pawaStream: (element: HTMLElement, context: any, statecontext?: any) => void;
125
+ }
126
+
81
127
  export interface PawaComment extends Comment {
82
128
  _index: number | null;
83
129
  _el: Comment;
@@ -163,11 +209,11 @@ export function pluginsMap(): {
163
209
  pawaAttributes: Set<string>;
164
210
  allowAsProp: Set<string>;
165
211
  };
166
- export function PawaCustomEvent(eventType:string,handler:(el:PawaElement,modifiers:Set,options:{
212
+ export function PawaCustomEvent(eventType:string,handler:(el:PawaElement,modifiers:Set<string>,options:{
167
213
  capture: Boolean,
168
214
  once: Boolean,
169
215
  passive: Boolean
170
- },execute:(e:EventListener)=>void)=>{})
216
+ },execute:(e:EventListener)=>void)=>void):void;
171
217
  export const escapePawaAttribute: Set<string>;
172
218
  export const dependentPawaAttribute: Set<string>;
173
219
 
@@ -218,9 +264,10 @@ export function RegisterComponent(...args: (string | Function)[]): void;
218
264
 
219
265
  export namespace RegisterComponent {
220
266
  /**
221
- * Registers components lazily. The component's bundle is only fetched when the element enters the viewport.
267
+ * Registers components lazily. The component's bundle is only fetched during runime encounter.
268
+ * (nam,import) or ([names,...],import)
222
269
  */
223
- export function lazy(...args: (string | Function)[]): Promise<void>;
270
+ export function lazy(...args: (string | Array<string> | Function)[]): Promise<void>;
224
271
  }
225
272
 
226
273
  /**
@@ -321,7 +368,7 @@ export function setStateContext(context: any): any;
321
368
  * @param {string | null | string[]} [section] - Persistence key or dependency array.
322
369
  * @returns {State<T>} Reactive state object.
323
370
  */
324
- export function $state<T>(initialValue: StateInput<T>, section?: string | null | string[]): State<T>;
371
+ export function $state<T>(initialValue: StateInput<T>, section?: string | null | Function[] | Object[] | string[]): State<T>;
325
372
 
326
373
  export function restoreContext(state_context: any): void;
327
374
 
package/index.js CHANGED
@@ -198,7 +198,8 @@ export const lazyComponents=new Map()
198
198
  /**
199
199
  * @type {PawaComponent}
200
200
  */
201
- let stateContext = {
201
+
202
+ let stateContext = {
202
203
  _hasRun: false,
203
204
  _formerContext: null,
204
205
  _insert: {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pawajs",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "type":"module",
5
5
  "description": "pawajs library (reactive web runtime) for easily building web ui, enhancing html element, micro frontend etc ",
6
6
  "main": "index.js",
package/power.js CHANGED
@@ -547,6 +547,32 @@ export const documentEvent = (el, attr) => {
547
547
  };
548
548
 
549
549
  const target = modifiers.has('window') ? window : document;
550
+
551
+ // Wrapper to ensure custom events respect standard action and "out" modifiers
552
+ const wrappedExecute = (e) => {
553
+ // Apply common modifiers first
554
+ if (!checkCommonModifiers(e, modifiers)) return;
555
+ if (!checkKeyModifiers(e, modifiers, eventType)) return;
556
+
557
+ // ========== TARGET MODIFIERS (OUTSIDE LOGIC) ==========
558
+ // For out- events, 'self' means we ignore the event if it happens inside the element or on the element itself.
559
+ if (modifiers.has('self') && (e.target === el || el.contains(e.target))) return;
560
+ if (modifiers.has('not-self') && e.target === el) return;
561
+
562
+ // ========== ACTION MODIFIERS ==========
563
+ if (modifiers.has('prevent')) e.preventDefault?.();
564
+ if (modifiers.has('stop')) e.stopPropagation?.();
565
+
566
+ // ========== EXECUTION ==========
567
+ processEventExecution(el, attr.name, modifiers, () => executeOutEvent(e), eventType, 'out');
568
+ };
569
+
570
+ if (customEventMap.has(eventType)) {
571
+ const custom = customEventMap.get(eventType);
572
+ custom(el, modifiers, options, wrappedExecute);
573
+ return;
574
+ }
575
+
550
576
  el._MountFunctions.push(() => target.addEventListener(eventType, handler, options))
551
577
  const unMount = () => target.removeEventListener(eventType, handler, options);
552
578
  el._setUnMount(unMount)
package/server.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ export const isServer: () => boolean;
2
+ export const getServerInstance: () => {
3
+ useInsert: null;
4
+ useInnerContext: null;
5
+ setContext: null;
6
+ useContext: null;
7
+ $state: null;
8
+ accessChild: null;
9
+ useServer: null;
10
+ useAsync: null;
11
+ forwardPops: null;
12
+ };
13
+ export const setServer: (obj?: {}) => void;