apprun 3.36.0 → 3.37.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.
Files changed (93) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +143 -25
  3. package/WHATSNEW.md +29 -12
  4. package/apprun-book.jpg +0 -0
  5. package/apprun.d.ts +136 -46
  6. package/cli/app.js +29 -0
  7. package/cli/index.html +13 -0
  8. package/{apprun-cli.js → cli/index.js} +8 -14
  9. package/dist/apprun-code.js +2 -0
  10. package/dist/apprun-code.js.map +1 -0
  11. package/dist/apprun-dev-tools.js +1 -2
  12. package/dist/apprun-dev-tools.js.map +1 -1
  13. package/dist/apprun-html.esm.js +7 -7
  14. package/dist/apprun-html.esm.js.map +1 -1
  15. package/dist/apprun-html.js +1 -1
  16. package/dist/apprun-html.js.map +1 -1
  17. package/dist/apprun-play-html.esm.js +7 -7
  18. package/dist/apprun-play-html.esm.js.map +1 -1
  19. package/dist/apprun-play.js +1 -1
  20. package/dist/apprun-play.js.map +1 -1
  21. package/dist/apprun.esm.js +1 -1
  22. package/dist/apprun.esm.js.map +1 -1
  23. package/dist/apprun.js +1 -1
  24. package/dist/apprun.js.map +1 -1
  25. package/dist/createState.js +2 -0
  26. package/dist/createState.js.map +1 -0
  27. package/esm/add-components.js +90 -0
  28. package/esm/add-components.js.map +1 -0
  29. package/esm/app.js +15 -8
  30. package/esm/app.js.map +1 -1
  31. package/esm/apprun-code.js +51 -16
  32. package/esm/apprun-code.js.map +1 -1
  33. package/esm/apprun-dev-tools.js +32 -32
  34. package/esm/apprun-dev-tools.js.map +1 -1
  35. package/esm/apprun-play.js +50 -17
  36. package/esm/apprun-play.js.map +1 -1
  37. package/esm/apprun.js +42 -11
  38. package/esm/apprun.js.map +1 -1
  39. package/esm/component.js +17 -20
  40. package/esm/component.js.map +1 -1
  41. package/esm/createState.js +9 -0
  42. package/esm/createState.js.map +1 -0
  43. package/esm/decorator.js.map +1 -1
  44. package/esm/directive.js +1 -1
  45. package/esm/directive.js.map +1 -1
  46. package/esm/router.js +241 -18
  47. package/esm/router.js.map +1 -1
  48. package/esm/shadow.js +1 -1
  49. package/esm/shadow.js.map +1 -1
  50. package/esm/type-utils.js +2 -3
  51. package/esm/type-utils.js.map +1 -1
  52. package/esm/vdom-my-new.js +327 -0
  53. package/esm/vdom-my-new.js.map +1 -0
  54. package/esm/vdom-my-prop-attr.js +227 -0
  55. package/esm/vdom-my-prop-attr.js.map +1 -0
  56. package/esm/vdom-my.js +114 -150
  57. package/esm/vdom-my.js.map +1 -1
  58. package/esm/vdom-patch.js +1 -1
  59. package/esm/vdom-patch.js.map +1 -1
  60. package/esm/version.js +1 -1
  61. package/esm/web-component.js +3 -4
  62. package/esm/web-component.js.map +1 -1
  63. package/index.html +5 -2
  64. package/jest.config.js +2 -2
  65. package/jest.setup.js +29 -3
  66. package/jsx-runtime.js +1 -1
  67. package/jsx-runtime.js.map +1 -1
  68. package/package.json +14 -14
  69. package/src/add-components.ts +103 -0
  70. package/src/app.ts +10 -19
  71. package/src/apprun-code.tsx +48 -10
  72. package/src/apprun-dev-tools.tsx +23 -27
  73. package/src/apprun-play.tsx +46 -9
  74. package/src/apprun.ts +49 -40
  75. package/src/component.ts +15 -8
  76. package/src/createState.ts +11 -0
  77. package/src/decorator.ts +2 -1
  78. package/src/router.ts +261 -17
  79. package/src/shadow.tsx +1 -1
  80. package/src/tsconfig.json +2 -2
  81. package/src/types.ts +62 -2
  82. package/src/vdom-my-new.ts +311 -0
  83. package/src/vdom-my-prop-attr.ts +241 -0
  84. package/src/vdom-my.ts +109 -134
  85. package/src/version.ts +1 -1
  86. package/src/web-component.ts +4 -10
  87. package/tsconfig.jest.json +15 -6
  88. package/tsconfig.json +3 -3
  89. package/webpack.config.cjs +3 -1
  90. package/cli/export.js +0 -92
  91. package/cli/import.js +0 -68
  92. package/plan/plan-apprun-bugfixes.md +0 -207
  93. package/src/types/apprun.d.ts +0 -56
@@ -1,207 +0,0 @@
1
- # AppRun.ts Bug Fixes Implementation Plan
2
-
3
- ## 🎉 PHASE 1 COMPLETE: All Critical Bugs Fixed!
4
-
5
- **Status**: All 4 critical Phase 1 bugs have been successfully resolved and committed.
6
-
7
- **Commits**: `072d033`, `fc6469f`, router fix, `93e0371`
8
-
9
- **Impact**:
10
- - ✅ TypeScript declarations now match implementation perfectly
11
- - ✅ Version consistency established across all files
12
- - ✅ Router initialization logic corrected (critical routing bug fixed)
13
- - ✅ React 18+ integration improved with proper validation
14
-
15
- ## Overview
16
- This plan addresses the critical bugs and issues identified in the AppRun framework, focusing on the main `apprun.ts` file and related dependencies. The fixes are prioritized by severity and impact.
17
-
18
- ## ✅ Completed Fixes
19
-
20
- ### 1. TypeScript Declaration File Mismatches - **COMPLETED**
21
- - [x] **CRITICAL**: Fix `IApp.use_react` signature mismatch
22
- - d.ts: `use_react(React, ReactDOM)`
23
- - Implementation: `use_react(createRoot)` - Fixed parameter signature!
24
- - [x] Fix missing `once` method in `IApp` interface implementation
25
- - [x] Fix missing `query` method in `IApp` interface (marked obsolete but still exists)
26
- - [x] Fix missing `version` property in IApp interface implementation
27
- - [x] Fix missing `mounted` callback in `AppStartOptions<T>` interface
28
- - [x] Fix `Component.render` method signature mismatch - Removed from d.ts
29
- - [x] Fix `AppStartOptions` missing `mounted` callback parameter
30
- - [x] Sync VNode type definition between d.ts and types.ts
31
- - **Git Commit**: `072d033` - All TypeScript declaration mismatches resolved
32
-
33
- ### 2. Version Synchronization - **COMPLETED**
34
- - [x] Fix version mismatch between `apprun.ts` (3.35.0) and `app.ts` (3.3.11)
35
- - [x] Establish single source of truth for version management
36
- - [x] Update version constants to match across all files
37
- - **Implementation**: Created `/src/version.ts` utility with `APPRUN_VERSION` constant
38
- - **Git Commit**: Ready for commit
39
-
40
- ## High Priority Fixes (Critical Bugs)
41
-
42
- ### 2. Version Synchronization - **COMPLETED**
43
- - [x] Fix version mismatch between `apprun.ts` (3.35.0) and `app.ts` (3.3.11)
44
- - [x] Establish single source of truth for version management
45
- - [x] Update version constants to match across all files
46
- - **Implementation**: Created `/src/version.ts` utility with `APPRUN_VERSION` constant
47
- - **Git Commit**: Ready for commit
48
-
49
- ### 3. Router Logic Correction - **COMPLETED**
50
- - [x] Fix inverted router initialization logic in `apprun.ts` lines 134-137
51
- - Problem: `init_load && route()` should be `!init_load && route()`
52
- - When `apprun-no-init` attribute is present, routing should be DISABLED
53
- - Current logic routes when disabled and doesn't route when enabled (inverted!)
54
- - **Fixed**: Changed logic to `!init_load && route()` for correct behavior
55
- - [x] Correct `init_load` boolean logic to properly respect no-init flags
56
- - [x] Test router behavior with and without init flags
57
-
58
- ### 4. React 18+ Integration Fix
59
- - [X] Fix missing `ReactDOM` parameter in `use_react` method (matches d.ts issue above)
60
- - [X] Ensure React 18+ createRoot functionality works correctly
61
- - [X] Add proper parameter validation for React integration
62
-
63
- ## Medium Priority Fixes (Type Safety & Reliability)
64
-
65
- ### 5. Additional TypeScript Declaration Mismatches
66
-
67
- ### 6. Type Safety Improvements - **COMPLETED**
68
- - [x] Add null checks before type assertions in event handlers
69
- - [x] Improve generic type constraints for window object assignments
70
- - [x] Add proper TypeScript types for global assignments
71
- - [x] Enhanced React integration parameter validation
72
- - [x] Better error handling in event system
73
- - [x] Safer DOM element access with proper validation
74
- - **Implementation**: Enhanced type safety across multiple files
75
- - **Git Commit**: Ready for commit
76
-
77
- ### 7. Memory Leak Prevention
78
- - [ ] Implement cleanup mechanism for DOM event listeners
79
- - [ ] Add component cache cleanup strategy
80
- - [ ] Create proper unsubscribe methods for router events
81
-
82
- ### 8. Global State Management
83
- - [ ] Preserve existing React global before overwriting
84
- - [ ] Add safety checks for global object modifications
85
- - [ ] Implement proper global state restoration
86
-
87
- ## Low Priority Fixes (Performance & Edge Cases)
88
-
89
- ### 9. Document Ready State Handling
90
- - [ ] Add check for document.readyState === 'complete'
91
- - [ ] Handle late script loading scenarios
92
- - [ ] Ensure initialization occurs regardless of load timing
93
-
94
- ### 10. Router Edge Cases
95
- - [ ] Add validation for malformed URLs
96
- - [ ] Implement error boundaries for routing failures
97
- - [ ] Handle empty/undefined route scenarios
98
-
99
- ### 11. Performance Optimizations
100
- - [ ] Cache expensive DOM queries (`app.find('#')`, `app.find('#/')`)
101
- - [ ] Optimize repeated lookups in router logic
102
- - [ ] Reduce unnecessary event listener registrations
103
-
104
- ## Testing & Validation
105
-
106
- ### 12. Test Coverage - **COMPLETED**
107
- - [x] Create unit tests for fixed router logic
108
- - [x] Add integration tests for React compatibility
109
- - [x] Test memory leak scenarios with repeated component mounting
110
- - [x] Validate version consistency across builds
111
- - [x] Test TypeScript declaration file accuracy
112
- - **Implementation**: Created comprehensive test suites covering all critical bug fixes
113
- - `router-fix.spec.ts`: Tests router initialization logic and no-init attribute behavior
114
- - `react-compatibility.spec.ts`: Tests React 18+ integration and parameter validation
115
- - `memory-leak.spec.ts`: Tests component lifecycle and event system memory management
116
- - `version-consistency.spec.ts`: Tests version synchronization and single source of truth
117
- - `typescript-declarations.spec.ts`: Tests TypeScript interface compliance and accuracy
118
- - **Git Commit**: Ready for commit
119
-
120
- ### 13. Regression Testing
121
- - [ ] Test existing functionality after each fix
122
- - [ ] Verify backward compatibility
123
- - [ ] Check for any breaking changes in public API
124
-
125
- ## Implementation Strategy
126
-
127
- ### Phase 1: Critical Fixes
128
- 1. TypeScript declaration file mismatches
129
- 2. Version synchronization
130
- 3. Router logic correction
131
- 4. React integration fix
132
-
133
- ### Phase 2: Safety & Reliability
134
- 5. Additional TypeScript declaration mismatches
135
- 6. Type safety improvements
136
- 7. Memory leak prevention
137
- 8. Global state management
138
-
139
- ### Phase 3: Polish & Optimization
140
- 9. Document ready state handling
141
- 10. Router edge cases
142
- 11. Performance optimizations
143
- 12. Testing & validation
144
-
145
- ## Files to be Modified
146
-
147
- ### Primary Files
148
- - [ ] `/src/apprun.ts` - Main entry point fixes
149
- - [ ] `/src/app.ts` - Version constant update
150
- - [ ] `/src/router.ts` - Edge case handling
151
- - [ ] `/apprun.d.ts` - TypeScript declaration fixes
152
-
153
- ### Secondary Files
154
- - [ ] `/src/types.ts` - Type safety improvements
155
- - [ ] `/src/component.ts` - Memory management fixes
156
-
157
- ### New Files
158
- - [ ] Create version management utility
159
- - [ ] Add cleanup utility functions
160
- - [ ] Create router validation helpers
161
-
162
- ## Risk Assessment
163
-
164
- ### Low Risk
165
- - Version synchronization
166
- - Type safety improvements
167
- - Performance optimizations
168
- - TypeScript declaration fixes
169
-
170
- ### Medium Risk
171
- - Router logic changes
172
- - Memory management modifications
173
- - Global state handling
174
-
175
- ### High Risk
176
- - React integration changes (potential breaking changes)
177
- - Event listener cleanup (could affect existing apps)
178
-
179
- ## Rollback Strategy
180
- - [ ] Create backup of current working version
181
- - [ ] Implement feature flags for major changes
182
- - [ ] Maintain backward compatibility where possible
183
- - [ ] Document any breaking changes clearly
184
-
185
- ## Success Criteria
186
- - [ ] All identified bugs fixed without introducing new issues
187
- - [ ] No breaking changes to public API
188
- - [ ] Memory usage remains stable or improves
189
- - [ ] Router functionality works correctly in all scenarios
190
- - [ ] React integration works with all supported versions
191
- - [ ] All tests pass including new regression tests
192
-
193
- ## Timeline Estimate
194
- - Phase 1 (Critical): 2-3 days
195
- - Phase 2 (Safety): 2-3 days
196
- - Phase 3 (Polish): 1-2 days
197
- - Testing & Validation: 1-2 days
198
- - **Total Estimated Time: 6-10 days**
199
-
200
- ## Dependencies
201
- - No external dependencies for core fixes
202
- - May need to update build scripts for version management
203
- - Testing framework should be available for validation
204
-
205
- ---
206
-
207
- **Note**: This plan should be reviewed and approved before implementation begins. Each checkbox represents a discrete task that can be implemented and tested independently.
@@ -1,56 +0,0 @@
1
- declare type VNode = {
2
- tag: string;
3
- props?: Record<string, any>;
4
- children?: Array<VNode | string | number>;
5
- } | string | number;
6
-
7
- declare type VDOM = VNode | VNode[];
8
-
9
- declare type View<T = any> = (state: T) => VDOM | void;
10
- declare type Action<T = any> = (state: T, ...p: any[]) => T | void | Promise<T>;
11
- declare type ActionDef<T = any> = [Action<T>, object?];
12
- declare type Update<T = any> = { [name: string]: Action<T> | ActionDef<T> | Array<Action<T> | ActionDef<T>> };
13
-
14
- declare interface IApp {
15
- start<T>(element?: Element | string | null, model?: T, view?: View<T>, update?: Update<T>, options?: AppStartOptions): Component<T>;
16
- on(name: string, fn: (...args: any[]) => void, options?: any): void;
17
- run(name: string, ...args: any[]): void;
18
- createElement(tag: string | Function, props?: any, ...children: any[]): VNode;
19
- render(element: Element, node: VNode): void;
20
- }
21
-
22
- declare interface Component<T = any> {
23
- readonly state: T;
24
- setState(state: T, options?: any): void;
25
- mount(element?: Element | string | null, options?: any): Component<T>;
26
- start(element?: Element | string | null, options?: any): Component<T>;
27
- run(name: string, ...args: any[]): void;
28
- rendered?: (state: T) => void;
29
- view?: View<T>;
30
- update?: Update<T>;
31
- element?: Element;
32
- }
33
-
34
- declare interface CustomElementOptions {
35
- render?: boolean;
36
- shadow?: boolean;
37
- history?: boolean | { prev: string; next: string };
38
- global_event?: boolean;
39
- route?: string;
40
- }
41
-
42
- declare interface AppStartOptions extends CustomElementOptions {
43
- render?: boolean;
44
- history?: boolean | { prev: string; next: string };
45
- global_event?: boolean;
46
- route?: string;
47
- }
48
-
49
- declare interface Route {
50
- (url: string): void;
51
- push(url: string, notify?: boolean): void;
52
- }
53
-
54
- declare const app: IApp;
55
- declare function on<T = any>(name?: string, options?: any): (target: any, key: string) => void;
56
- declare function Component<T = any>(options?: any): (constructor: Function) => void;