apprun 3.36.1 → 3.37.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/CHANGELOG.md +14 -4
- package/README.md +37 -32
- package/WHATSNEW.md +12 -3
- package/apprun.d.ts +134 -47
- package/dist/apprun-code.js +2 -0
- package/dist/apprun-code.js.map +1 -0
- package/dist/apprun-dev-tools.js +1 -1
- package/dist/apprun-dev-tools.js.map +1 -1
- package/dist/apprun-html.esm.js +7 -7
- package/dist/apprun-html.esm.js.map +1 -1
- package/dist/apprun-html.js +1 -1
- package/dist/apprun-html.js.map +1 -1
- package/dist/apprun-play-html.esm.js +7 -7
- package/dist/apprun-play-html.esm.js.map +1 -1
- package/dist/apprun-play.js +1 -1
- package/dist/apprun-play.js.map +1 -1
- package/dist/apprun.esm.js +1 -1
- package/dist/apprun.esm.js.map +1 -1
- package/dist/apprun.js +1 -1
- package/dist/apprun.js.map +1 -1
- package/dist/createState.js +2 -0
- package/dist/createState.js.map +1 -0
- package/esm/add-components.js +90 -0
- package/esm/add-components.js.map +1 -0
- package/esm/app.js +5 -2
- package/esm/app.js.map +1 -1
- package/esm/apprun-code.js +51 -16
- package/esm/apprun-code.js.map +1 -1
- package/esm/apprun-dev-tools.js +31 -25
- package/esm/apprun-dev-tools.js.map +1 -1
- package/esm/apprun-play.js +50 -17
- package/esm/apprun-play.js.map +1 -1
- package/esm/apprun.js +24 -7
- package/esm/apprun.js.map +1 -1
- package/esm/component.js +13 -20
- package/esm/component.js.map +1 -1
- package/esm/createState.js +9 -0
- package/esm/createState.js.map +1 -0
- package/esm/decorator.js.map +1 -1
- package/esm/directive.js +1 -1
- package/esm/directive.js.map +1 -1
- package/esm/router.js.map +1 -1
- package/esm/shadow.js +1 -1
- package/esm/shadow.js.map +1 -1
- package/esm/type-utils.js +2 -3
- package/esm/type-utils.js.map +1 -1
- package/esm/vdom-my-new.js +8 -10
- package/esm/vdom-my-new.js.map +1 -1
- package/esm/vdom-my.js +7 -9
- package/esm/vdom-my.js.map +1 -1
- package/esm/vdom-patch.js +1 -1
- package/esm/vdom-patch.js.map +1 -1
- package/esm/version.js +1 -1
- package/esm/web-component.js +3 -4
- package/esm/web-component.js.map +1 -1
- package/index.html +5 -2
- package/jest.config.js +0 -1
- package/jsx-runtime.js +1 -1
- package/jsx-runtime.js.map +1 -1
- package/package.json +11 -11
- package/src/add-components.ts +103 -0
- package/src/app.ts +0 -14
- package/src/apprun-code.tsx +48 -10
- package/src/apprun-dev-tools.tsx +22 -20
- package/src/apprun-play.tsx +46 -9
- package/src/apprun.ts +28 -37
- package/src/component.ts +11 -8
- package/src/createState.ts +11 -0
- package/src/decorator.ts +2 -1
- package/src/router.ts +2 -2
- package/src/shadow.tsx +1 -1
- package/src/tsconfig.json +2 -2
- package/src/types.ts +62 -2
- package/src/version.ts +1 -1
- package/src/web-component.ts +4 -10
- package/tsconfig.jest.json +15 -6
- package/tsconfig.json +3 -3
- package/webpack.config.cjs +3 -1
- package/src/types/apprun.d.ts +0 -56
package/src/types.ts
CHANGED
|
@@ -59,10 +59,10 @@ export type VDOM = false | string | VNode | Array<VNode | string> | TemplateResu
|
|
|
59
59
|
export type View<T> = (state: T) => VDOM | void;
|
|
60
60
|
export type Action<T> = (state: T, ...p: any[]) => T | Promise<T> | void;
|
|
61
61
|
export type ActionDef<T, E> = (readonly [E, Action<T>, {}?]);
|
|
62
|
-
export type Update<T, E =
|
|
62
|
+
export type Update<T, E = any> = ActionDef<T, E>[] | { [name: string]: Action<T> | {}[] } | (E | Action<T> | {})[];
|
|
63
63
|
export type ActionOptions = {
|
|
64
64
|
render?: boolean, history?, global?: boolean;
|
|
65
|
-
callback?: (state) => void;
|
|
65
|
+
callback?: (state: any) => void;
|
|
66
66
|
};
|
|
67
67
|
export type EventOptions = {
|
|
68
68
|
once?: boolean;
|
|
@@ -82,3 +82,63 @@ export type AppStartOptions<T> = {
|
|
|
82
82
|
rendered?: (state: T) => void
|
|
83
83
|
mounted?: (props: any, children: any, state: T) => T
|
|
84
84
|
};
|
|
85
|
+
export type Router = (url: string, ...args: any[]) => any;
|
|
86
|
+
|
|
87
|
+
export type CustomElementOptions = {
|
|
88
|
+
render?: boolean;
|
|
89
|
+
shadow?: boolean;
|
|
90
|
+
history?: boolean;
|
|
91
|
+
global_event?: boolean;
|
|
92
|
+
observedAttributes?: string[];
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export interface IApp {
|
|
96
|
+
// Event system methods
|
|
97
|
+
on(name: string, fn: (...args: any[]) => any, options?: EventOptions): void;
|
|
98
|
+
off(name: string, fn: (...args: any[]) => any): void;
|
|
99
|
+
run(name: string, ...args: any[]): number;
|
|
100
|
+
runAsync(name: string, ...args: any[]): Promise<any[]>;
|
|
101
|
+
once(name: string, fn: (...args: any[]) => any, options?: EventOptions): void;
|
|
102
|
+
find(name: string): any;
|
|
103
|
+
|
|
104
|
+
/** @deprecated Use runAsync() instead */
|
|
105
|
+
query(name: string, ...args: any[]): Promise<any[]>;
|
|
106
|
+
|
|
107
|
+
start<T, E = any>(element?: Element | string, model?: T, view?: View<T>, update?: Update<T, E>,
|
|
108
|
+
options?: AppStartOptions<T>): any;
|
|
109
|
+
|
|
110
|
+
h(tag: string | Function, props?: any, ...children: any[]): VNode | VNode[];
|
|
111
|
+
createElement(tag: string | Function, props?: any, ...children: any[]): VNode | VNode[];
|
|
112
|
+
render(element: Element | ShadowRoot, node: VNode, component?: {}): void;
|
|
113
|
+
Fragment(props: any, ...children: any[]): any[];
|
|
114
|
+
route: Router;
|
|
115
|
+
webComponent(name: string, componentClass: any, options?: CustomElementOptions): void;
|
|
116
|
+
safeHTML(html: string): any[];
|
|
117
|
+
use_render(render: any, mode?: 0 | 1): void;
|
|
118
|
+
use_react(React: any, ReactDOM: any): void;
|
|
119
|
+
version: string;
|
|
120
|
+
basePath?: string;
|
|
121
|
+
addComponents: (element: Element | string, components: ComponentRoute) => void;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Define what constitutes a mountable component
|
|
125
|
+
interface ComponentLike {
|
|
126
|
+
mount(element?: Element | string, options?: any): any;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Define component constructor type
|
|
130
|
+
type ComponentConstructor<T = any> = new (
|
|
131
|
+
state?: T,
|
|
132
|
+
view?: any,
|
|
133
|
+
update?: any,
|
|
134
|
+
options?: any
|
|
135
|
+
) => ComponentLike;
|
|
136
|
+
|
|
137
|
+
// Enhanced ComponentRoute type with clear distinctions
|
|
138
|
+
export type ComponentRoute = {
|
|
139
|
+
[route: string]:
|
|
140
|
+
| ComponentLike // Component instance
|
|
141
|
+
| ComponentConstructor // Component class constructor
|
|
142
|
+
| (() => ComponentLike | ComponentConstructor | Promise<ComponentLike | ComponentConstructor>) // Factory function
|
|
143
|
+
| ((...args: any[]) => any) // Event handler function
|
|
144
|
+
};
|
package/src/version.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
// Import version from package.json to maintain single source of truth
|
|
12
12
|
// This version string is used across the framework
|
|
13
|
-
export const APPRUN_VERSION = '3.
|
|
13
|
+
export const APPRUN_VERSION = '3.37.1';
|
|
14
14
|
|
|
15
15
|
// Version string with prefix for global tracking
|
|
16
16
|
export const APPRUN_VERSION_GLOBAL = `AppRun-${APPRUN_VERSION}`;
|
package/src/web-component.ts
CHANGED
|
@@ -53,18 +53,12 @@
|
|
|
53
53
|
|
|
54
54
|
declare var customElements;
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
render?: boolean;
|
|
58
|
-
shadow?: boolean;
|
|
59
|
-
history?: boolean;
|
|
60
|
-
global_event?: boolean;
|
|
61
|
-
observedAttributes?: string[];
|
|
62
|
-
};
|
|
56
|
+
import { CustomElementOptions } from './types';
|
|
63
57
|
|
|
64
58
|
export const customElement = (componentClass, options: CustomElementOptions = {}) => class CustomElement extends HTMLElement {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
public _shadowRoot;
|
|
60
|
+
public _component;
|
|
61
|
+
public _attrMap: (arg0: string) => string;
|
|
68
62
|
public on;
|
|
69
63
|
public run;
|
|
70
64
|
constructor() {
|
package/tsconfig.jest.json
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
4
|
-
"module": "
|
|
3
|
+
"target": "es2020",
|
|
4
|
+
"module": "esnext",
|
|
5
5
|
"moduleResolution": "node",
|
|
6
6
|
"jsx": "react",
|
|
7
7
|
"reactNamespace": "app",
|
|
8
|
-
"lib": [
|
|
8
|
+
"lib": [
|
|
9
|
+
"dom",
|
|
10
|
+
"esnext"
|
|
11
|
+
],
|
|
9
12
|
"experimentalDecorators": true,
|
|
10
13
|
"sourceMap": true,
|
|
11
14
|
"esModuleInterop": true,
|
|
12
15
|
"downlevelIteration": true,
|
|
13
16
|
"allowJs": true,
|
|
14
17
|
"outDir": "coverage/src",
|
|
18
|
+
"isolatedModules": true,
|
|
15
19
|
"strict": true,
|
|
16
20
|
"noImplicitAny": true,
|
|
17
21
|
"strictNullChecks": true,
|
|
@@ -24,17 +28,22 @@
|
|
|
24
28
|
"forceConsistentCasingInFileNames": true,
|
|
25
29
|
"baseUrl": ".",
|
|
26
30
|
"paths": {
|
|
27
|
-
"*": [
|
|
31
|
+
"*": [
|
|
32
|
+
"src/types/*"
|
|
33
|
+
]
|
|
28
34
|
},
|
|
29
35
|
"typeRoots": [
|
|
30
36
|
"./node_modules/@types",
|
|
31
37
|
"./src/types"
|
|
32
38
|
],
|
|
33
|
-
"types": [
|
|
39
|
+
"types": [
|
|
40
|
+
"jest",
|
|
41
|
+
"node"
|
|
42
|
+
]
|
|
34
43
|
},
|
|
35
44
|
"include": [
|
|
36
45
|
"src/**/*",
|
|
37
46
|
"tests/**/*",
|
|
38
47
|
"demo/**/*"
|
|
39
48
|
]
|
|
40
|
-
}
|
|
49
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
4
|
-
"module": "
|
|
3
|
+
"target": "es2020",
|
|
4
|
+
"module": "esnext",
|
|
5
5
|
"moduleResolution": "node",
|
|
6
6
|
"jsx": "react",
|
|
7
7
|
"jsxFactory": "app.h",
|
|
8
8
|
"jsxFragmentFactory": "app.Fragment",
|
|
9
|
-
"lib": ["dom", "
|
|
9
|
+
"lib": ["dom", "es2020", "esnext.asynciterable"],
|
|
10
10
|
"experimentalDecorators": true,
|
|
11
11
|
"sourceMap": true,
|
|
12
12
|
"esModuleInterop": true,
|
package/webpack.config.cjs
CHANGED
|
@@ -5,9 +5,11 @@ module.exports = {
|
|
|
5
5
|
entry: {
|
|
6
6
|
'dist/apprun': './src/apprun.ts',
|
|
7
7
|
'dist/apprun-play': './src/apprun-play.tsx',
|
|
8
|
+
'dist/apprun-code': './src/apprun-code.tsx',
|
|
8
9
|
'dist/apprun-html': './src/apprun-html.ts',
|
|
9
|
-
'./jsx-runtime': './src/vdom.ts',
|
|
10
10
|
'dist/apprun-dev-tools': './src/apprun-dev-tools.tsx',
|
|
11
|
+
'dist/createState': './src/createState.ts',
|
|
12
|
+
'jsx-runtime': './src/vdom.ts',
|
|
11
13
|
'demo/app': './demo/main.ts'
|
|
12
14
|
},
|
|
13
15
|
output: {
|
package/src/types/apprun.d.ts
DELETED
|
@@ -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;
|