apprun 3.37.0 → 3.37.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/CHANGELOG.md +21 -4
- package/README.md +3 -0
- package/ai/apprun-html.prompt.md +290 -0
- package/ai/apprun.prompt.md +166 -0
- package/apprun.d.ts +7 -4
- package/dist/apprun-code.js +1 -1
- package/dist/apprun-code.js.map +1 -1
- package/dist/apprun-dev-tools.js +1 -1
- package/dist/apprun-dev-tools.js.map +1 -1
- package/dist/apprun-html.esm.js +1 -1
- 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 +1 -1
- 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/esm/apprun.js +2 -7
- package/esm/apprun.js.map +1 -1
- package/esm/component.js.map +1 -1
- package/esm/types.js +9 -3
- package/esm/types.js.map +1 -1
- package/esm/version.js +1 -1
- package/jsx-runtime.js +1 -1
- package/jsx-runtime.js.map +1 -1
- package/package.json +4 -4
- package/src/apprun.ts +3 -8
- package/src/component.ts +4 -6
- package/src/types.ts +11 -4
- package/src/version.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apprun",
|
|
3
|
-
"version": "3.37.
|
|
3
|
+
"version": "3.37.2",
|
|
4
4
|
"description": "JavaScript library that has Elm inspired architecture, event pub-sub and components",
|
|
5
5
|
"main": "dist/apprun.js",
|
|
6
6
|
"module": "esm/apprun.js",
|
|
@@ -44,10 +44,8 @@
|
|
|
44
44
|
"jest": "^29.7.0",
|
|
45
45
|
"jest-environment-jsdom": "^29.7.0",
|
|
46
46
|
"json-loader": "^0.5.7",
|
|
47
|
-
"immer": "^10.1.1",
|
|
48
47
|
"lit": "^3.3.1",
|
|
49
48
|
"marked": "^16.0.0",
|
|
50
|
-
"property-information": "^7.1.0",
|
|
51
49
|
"rollup": "^4.45.1",
|
|
52
50
|
"ts-jest": "^29.4.0",
|
|
53
51
|
"ts-loader": "^9.5.2",
|
|
@@ -57,6 +55,8 @@
|
|
|
57
55
|
"webpack-dev-server": "^5.2.2"
|
|
58
56
|
},
|
|
59
57
|
"dependencies": {
|
|
60
|
-
"commander": "^14.0.0"
|
|
58
|
+
"commander": "^14.0.0",
|
|
59
|
+
"immer": "^10.1.1",
|
|
60
|
+
"property-information": "^7.1.0"
|
|
61
61
|
}
|
|
62
62
|
}
|
package/src/apprun.ts
CHANGED
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
import _app, { App } from './app';
|
|
65
65
|
import { createElement, render, Fragment, safeHTML } from './vdom';
|
|
66
66
|
import { Component } from './component';
|
|
67
|
-
import { IApp, VNode, View, Action, Update, EventOptions, ActionOptions, MountOptions, AppStartOptions, CustomElementOptions } from './types';
|
|
67
|
+
import { IApp, VNode, State, View, Action, Update, EventOptions, ActionOptions, MountOptions, AppStartOptions, CustomElementOptions } from './types';
|
|
68
68
|
import { on, update, customElement } from './decorator';
|
|
69
69
|
import { route, ROUTER_EVENT, ROUTER_404_EVENT } from './router';
|
|
70
70
|
import webComponent from './web-component';
|
|
@@ -109,10 +109,10 @@ if (!app.start) {
|
|
|
109
109
|
app.webComponent = webComponent;
|
|
110
110
|
app.safeHTML = safeHTML;
|
|
111
111
|
|
|
112
|
-
app.start = <T, E = any>(element?: Element | string,
|
|
112
|
+
app.start = <T, E = any>(element?: Element | string, state?: State<T>, view?: View<T>, update?: Update<T, E>,
|
|
113
113
|
options?: AppStartOptions<T>): Component<T, E> => {
|
|
114
114
|
const opts = { render: true, global_event: true, ...options };
|
|
115
|
-
const component = new Component<T, E>(
|
|
115
|
+
const component = new Component<T, E>(state, view, update);
|
|
116
116
|
if (options && options.rendered) component.rendered = options.rendered;
|
|
117
117
|
if (options && options.mounted) component.mounted = options.mounted;
|
|
118
118
|
component.start(element, opts);
|
|
@@ -131,11 +131,6 @@ if (!app.start) {
|
|
|
131
131
|
app.on('route', url => app['route'] && app['route'](url));
|
|
132
132
|
|
|
133
133
|
if (typeof document === 'object') {
|
|
134
|
-
let basePath = location.pathname;
|
|
135
|
-
if (basePath.endsWith('/')) {
|
|
136
|
-
basePath = basePath.slice(0, -1);
|
|
137
|
-
}
|
|
138
|
-
app.basePath = basePath;
|
|
139
134
|
document.addEventListener("DOMContentLoaded", () => {
|
|
140
135
|
const no_init_route = document.body.hasAttribute('apprun-no-init') || app['no-init-route'] || false;
|
|
141
136
|
const use_hash = app.find('#') || app.find('#/') || false;
|
package/src/component.ts
CHANGED
|
@@ -55,7 +55,7 @@ import _app, { App } from './app';
|
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
import { Reflect } from './decorator'
|
|
58
|
-
import { View, Update, ActionDef, ActionOptions, MountOptions, EventOptions, IApp } from './types';
|
|
58
|
+
import { State, View, Update, ActionDef, ActionOptions, MountOptions, EventOptions, IApp } from './types';
|
|
59
59
|
import directive from './directive';
|
|
60
60
|
import { safeQuerySelector, safeGetElementById } from './type-utils';
|
|
61
61
|
|
|
@@ -210,7 +210,7 @@ export class Component<T = any, E = any> {
|
|
|
210
210
|
};
|
|
211
211
|
|
|
212
212
|
constructor(
|
|
213
|
-
protected state?: T
|
|
213
|
+
protected state?: State<T>,
|
|
214
214
|
protected view?: View<T>,
|
|
215
215
|
protected update?: Update<T, E>,
|
|
216
216
|
protected options?) {
|
|
@@ -244,10 +244,8 @@ export class Component<T = any, E = any> {
|
|
|
244
244
|
|
|
245
245
|
this.add_actions();
|
|
246
246
|
this.state = this.state ?? this['model'] ?? {};
|
|
247
|
-
if (typeof this.state === 'function') this.state = this.state();
|
|
248
|
-
|
|
249
|
-
this.setState(this.state, { render: !!options.render, history: true });
|
|
250
|
-
|
|
247
|
+
if (typeof this.state === 'function') this.state = (this.state as Function)();
|
|
248
|
+
this.setState(this.state as T, { render: !!options.render, history: true });
|
|
251
249
|
if (app['debug'] && app.find('debug-create-component')?.length) {
|
|
252
250
|
app.run('debug-create-component', this);
|
|
253
251
|
}
|
package/src/types.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This file defines the fundamental types used across AppRun:
|
|
5
5
|
* 1. Component Types
|
|
6
6
|
* - View: Function that renders state to VDOM
|
|
7
|
-
* - Action: Function that updates state (sync/async)
|
|
7
|
+
* - Action: Function that updates state (sync/async/generator)
|
|
8
8
|
* - Update: Collection of actions (array or object format)
|
|
9
9
|
* - ActionDef: Tuple definition for action arrays
|
|
10
10
|
*
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
* - Improved union types for VDOM flexibility
|
|
34
34
|
* - Better callback typing in options
|
|
35
35
|
* - Stricter typing for lifecycle methods
|
|
36
|
+
* - Added support for async generator and generator functions in Action types
|
|
36
37
|
*
|
|
37
38
|
* Usage:
|
|
38
39
|
* ```ts
|
|
@@ -41,15 +42,21 @@
|
|
|
41
42
|
* update: Update<State, Events>;
|
|
42
43
|
* }
|
|
43
44
|
*
|
|
44
|
-
* // Type-safe action definitions
|
|
45
|
+
* // Type-safe action definitions with async generators
|
|
45
46
|
* const update: Update<State> = {
|
|
46
|
-
* 'event': (state: State, ...args) => newState
|
|
47
|
+
* 'event': (state: State, ...args) => newState,
|
|
48
|
+
* 'stream-event': async function* (state: State, ...args) {
|
|
49
|
+
* yield { ...state, loading: true };
|
|
50
|
+
* const data = await fetchData();
|
|
51
|
+
* yield { ...state, data, loading: false };
|
|
52
|
+
* }
|
|
47
53
|
* };
|
|
48
54
|
* ```
|
|
49
55
|
*/
|
|
50
56
|
|
|
51
57
|
import { TemplateResult } from 'lit-html';
|
|
52
58
|
export type Element = HTMLElement | string;
|
|
59
|
+
export type State<T> = T | Promise<T> | (() => T) | (() => Promise<T>);
|
|
53
60
|
export type VNode = {
|
|
54
61
|
tag: string | Function,
|
|
55
62
|
props: {},
|
|
@@ -57,7 +64,7 @@ export type VNode = {
|
|
|
57
64
|
}
|
|
58
65
|
export type VDOM = false | string | VNode | Array<VNode | string> | TemplateResult;
|
|
59
66
|
export type View<T> = (state: T) => VDOM | void;
|
|
60
|
-
export type Action<T> = (state: T, ...p: any[]) => T | Promise<T> | void
|
|
67
|
+
export type Action<T> = (state: T, ...p: any[]) => T | Promise<T> | void | AsyncGenerator<T> | Generator<T>;
|
|
61
68
|
export type ActionDef<T, E> = (readonly [E, Action<T>, {}?]);
|
|
62
69
|
export type Update<T, E = any> = ActionDef<T, E>[] | { [name: string]: Action<T> | {}[] } | (E | Action<T> | {})[];
|
|
63
70
|
export type ActionOptions = {
|
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.37.
|
|
13
|
+
export const APPRUN_VERSION = '3.37.2';
|
|
14
14
|
|
|
15
15
|
// Version string with prefix for global tracking
|
|
16
16
|
export const APPRUN_VERSION_GLOBAL = `AppRun-${APPRUN_VERSION}`;
|