apprun 3.38.0 → 6.0.0-rc.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.
- package/CHANGELOG.md +12 -1
- package/README.md +18 -10
- package/apprun.d.ts +67 -23
- 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 +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.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/add-components.js +7 -7
- package/esm/add-components.js.map +1 -1
- package/esm/app.js +81 -32
- package/esm/app.js.map +1 -1
- package/esm/apprun-code.js +8 -2
- package/esm/apprun-code.js.map +1 -1
- package/esm/apprun-html.js +14 -9
- package/esm/apprun-html.js.map +1 -1
- package/esm/apprun-play.js +7 -1
- package/esm/apprun-play.js.map +1 -1
- package/esm/apprun.js +38 -19
- package/esm/apprun.js.map +1 -1
- package/esm/component.js +90 -37
- package/esm/component.js.map +1 -1
- package/esm/directive.js +1 -1
- package/esm/directive.js.map +1 -1
- package/esm/router.js +73 -19
- package/esm/router.js.map +1 -1
- package/esm/types.js +2 -1
- package/esm/types.js.map +1 -1
- package/esm/vdom-my.js +52 -52
- package/esm/vdom-my.js.map +1 -1
- package/esm/vdom-to-html.js +8 -1
- package/esm/vdom-to-html.js.map +1 -1
- package/esm/vdom.js +3 -3
- package/esm/vdom.js.map +1 -1
- package/esm/version.js +1 -1
- package/esm/version.js.map +1 -1
- package/esm/web-component.js +23 -6
- package/esm/web-component.js.map +1 -1
- package/jsx-runtime.js +1 -1
- package/jsx-runtime.js.map +1 -1
- package/package.json +62 -2
- package/.clinerules +0 -1
- package/.travis.yml +0 -10
- package/BACKERS.md +0 -8
- package/CNAME +0 -1
- package/WHATSNEW.md +0 -367
- package/ai/apprun-html.prompt.md +0 -290
- package/ai/apprun.prompt.md +0 -602
- package/apprun-book.jpg +0 -0
- package/dist/apprun-dev-tools-tests.js +0 -1
- package/dist/apprun-dev-tools.js.LICENSE.txt +0 -1
- package/dist/apprun-play-html.esm.js +0 -34
- package/dist/apprun-play-html.esm.js.map +0 -1
- package/error.log +0 -0
- package/esm/apprun-play-html.js +0 -210
- package/esm/apprun-play-html.js.map +0 -1
- package/esm/shadow.js +0 -8
- package/esm/shadow.js.map +0 -1
- package/esm/vdom-html.js +0 -22
- package/esm/vdom-html.js.map +0 -1
- package/esm/vdom-my-new.js +0 -327
- package/esm/vdom-my-new.js.map +0 -1
- package/esm/vdom-patch.js +0 -103
- package/esm/vdom-patch.js.map +0 -1
- package/index.html +0 -87
- package/jest.config.js +0 -57
- package/jest.setup.js +0 -73
- package/logo.png +0 -0
- package/react.js +0 -13
- package/rollup.config.js +0 -62
- package/src/add-components.ts +0 -103
- package/src/app.ts +0 -173
- package/src/apprun-code.tsx +0 -177
- package/src/apprun-dev-tools-tests.tsx +0 -101
- package/src/apprun-dev-tools.tsx +0 -307
- package/src/apprun-html.ts +0 -25
- package/src/apprun-play.tsx +0 -249
- package/src/apprun.ts +0 -238
- package/src/component.ts +0 -388
- package/src/createState.ts +0 -11
- package/src/decorator.ts +0 -98
- package/src/directive.ts +0 -303
- package/src/global.d.ts +0 -22
- package/src/router.ts +0 -311
- package/src/shadow.tsx +0 -8
- package/src/tsconfig.json +0 -16
- package/src/type-utils.ts +0 -130
- package/src/types.ts +0 -151
- package/src/vdom-html.ts_ +0 -20
- package/src/vdom-lit-html.ts +0 -67
- package/src/vdom-my-new.ts +0 -311
- package/src/vdom-my-prop-attr.ts +0 -241
- package/src/vdom-my.ts +0 -286
- package/src/vdom-patch.ts +0 -108
- package/src/vdom-to-html.tsx +0 -49
- package/src/vdom.ts +0 -28
- package/src/version.ts +0 -16
- package/src/web-component.ts +0 -154
- package/tsconfig.jest.json +0 -49
- package/tsconfig.json +0 -16
- package/tslint.json +0 -114
- package/typescriptreact.json +0 -87
- package/viewEngine.js +0 -54
- package/webpack.config.cjs +0 -41
package/esm/vdom-patch.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
var CHANGES;
|
|
2
|
-
(function (CHANGES) {
|
|
3
|
-
CHANGES[CHANGES["NO_ATTR_CHANGE"] = 1] = "NO_ATTR_CHANGE";
|
|
4
|
-
CHANGES[CHANGES["NO_TREE_CHANGE"] = 2] = "NO_TREE_CHANGE";
|
|
5
|
-
})(CHANGES || (CHANGES = {}));
|
|
6
|
-
export function patch(vdom1, vdom2) {
|
|
7
|
-
if (!vdom1?.length || !vdom2?.length)
|
|
8
|
-
return;
|
|
9
|
-
const old_len = vdom1.length;
|
|
10
|
-
const new_len = vdom2.length;
|
|
11
|
-
const len = Math.min(old_len, new_len);
|
|
12
|
-
for (let i = 0; i < len; i++) {
|
|
13
|
-
const node1 = vdom1[i];
|
|
14
|
-
const node2 = vdom2[i];
|
|
15
|
-
if (!node2 || typeof node2 !== 'object')
|
|
16
|
-
continue;
|
|
17
|
-
if (_areEquals(node1, node2)) {
|
|
18
|
-
node2._op = CHANGES.NO_ATTR_CHANGE | CHANGES.NO_TREE_CHANGE;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
if (_areEquals(node1.props, node2.props)) {
|
|
22
|
-
node2._op = CHANGES.NO_ATTR_CHANGE;
|
|
23
|
-
}
|
|
24
|
-
if (_areEquals(node1.children, node2.children)) {
|
|
25
|
-
node2._op = node2._op | CHANGES.NO_TREE_CHANGE;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
patch(node1.children, node2.children);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export function get_vdom(node) {
|
|
34
|
-
if (!node)
|
|
35
|
-
return null;
|
|
36
|
-
if (node.nodeType === 3)
|
|
37
|
-
return node.nodeValue;
|
|
38
|
-
const children = [];
|
|
39
|
-
if (node.childNodes) {
|
|
40
|
-
for (let i = 0; i < node.childNodes.length; i++) {
|
|
41
|
-
children.push(get_vdom(node.childNodes[i]));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
const tag = node['tagName'] ? node['tagName'].toLocaleLowerCase() : node;
|
|
45
|
-
return {
|
|
46
|
-
tag,
|
|
47
|
-
props: node['_props'],
|
|
48
|
-
children
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
// based on https://github.com/epoberezkin/fast-deep-equal
|
|
52
|
-
// MIT License
|
|
53
|
-
// Copyright (c) 2017 Evgeny Poberezkin
|
|
54
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
55
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
56
|
-
// in the Software without restriction, including without limitation the rights
|
|
57
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
58
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
59
|
-
// furnished to do so, subject to the following conditions:
|
|
60
|
-
// The above copyright notice and this permission notice shall be included in all
|
|
61
|
-
// copies or substantial portions of the Software.
|
|
62
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
63
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
64
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
65
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
66
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
67
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
68
|
-
// SOFTWARE.
|
|
69
|
-
export function _areEquals(a, b) {
|
|
70
|
-
if (a === b)
|
|
71
|
-
return true;
|
|
72
|
-
if (a && b && typeof a == 'object' && typeof b == 'object') {
|
|
73
|
-
var arrA = Array.isArray(a), arrB = Array.isArray(b), i, length, key;
|
|
74
|
-
if (arrA && arrB) {
|
|
75
|
-
length = a.length;
|
|
76
|
-
if (length != b.length)
|
|
77
|
-
return false;
|
|
78
|
-
for (i = length; i-- !== 0;)
|
|
79
|
-
if (!_areEquals(a[i], b[i]))
|
|
80
|
-
return false;
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
if (arrA != arrB)
|
|
84
|
-
return false;
|
|
85
|
-
var keys = Object.keys(a);
|
|
86
|
-
length = keys.length;
|
|
87
|
-
if (length !== Object.keys(b).length)
|
|
88
|
-
return false;
|
|
89
|
-
for (i = length; i-- !== 0;)
|
|
90
|
-
if (!b.hasOwnProperty(keys[i]))
|
|
91
|
-
return false;
|
|
92
|
-
for (i = length; i-- !== 0;) {
|
|
93
|
-
key = keys[i];
|
|
94
|
-
if (!_areEquals(a[key], b[key]))
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
return a !== a && b !== b;
|
|
100
|
-
}
|
|
101
|
-
;
|
|
102
|
-
export default patch;
|
|
103
|
-
//# sourceMappingURL=vdom-patch.js.map
|
package/esm/vdom-patch.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vdom-patch.js","sourceRoot":"","sources":["../src/vdom-patch.ts"],"names":[],"mappings":"AAAA,IAAK,OAGJ;AAHD,WAAK,OAAO;IACV,yDAAkB,CAAA;IAClB,yDAAkB,CAAA;AACpB,CAAC,EAHI,OAAO,KAAP,OAAO,QAGX;AAED,MAAM,UAAU,KAAK,CAAC,KAAK,EAAE,KAAK;IAChC,IAAI,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,KAAK,EAAE,MA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
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
-
<title>AppRun</title>
|
|
7
|
-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
|
|
8
|
-
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
|
9
|
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css">
|
|
10
|
-
<link rel="stylesheet" href="demo/lib/codemirror.css">
|
|
11
|
-
<script src="demo/lib/codemirror.js"></script>
|
|
12
|
-
<script src="demo/mode/javascript/javascript.js"></script>
|
|
13
|
-
<script src="demo/mode/xml/xml.js"></script>
|
|
14
|
-
<script src="demo/mode/jsx/jsx.js"></script>
|
|
15
|
-
<link rel="stylesheet" type="text/css" href="demo/styles.css">
|
|
16
|
-
</head>
|
|
17
|
-
<body>
|
|
18
|
-
<!-- navbar -->
|
|
19
|
-
<nav class="navbar navbar-default">
|
|
20
|
-
<div class="container">
|
|
21
|
-
<div class="navbar-header">
|
|
22
|
-
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
|
23
|
-
<span class="sr-only">Toggle navigation</span>
|
|
24
|
-
<span class="icon-bar"></span>
|
|
25
|
-
<span class="icon-bar"></span>
|
|
26
|
-
<span class="icon-bar"></span>
|
|
27
|
-
</button>
|
|
28
|
-
<a class="navbar-brand" href="#">AppRun</a>
|
|
29
|
-
</div>
|
|
30
|
-
<div id="navbar" class="navbar-collapse collapse">
|
|
31
|
-
<ul class="nav navbar-nav navbar-right">
|
|
32
|
-
<li><a href="#new">What's New</a></li>
|
|
33
|
-
<li><a href="docs">Guide</a></li>
|
|
34
|
-
<li><a href="#play">Play</a></li>
|
|
35
|
-
<li class="dropdown">
|
|
36
|
-
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Examples
|
|
37
|
-
<span class="caret"></span></a>
|
|
38
|
-
<ul class="dropdown-menu">
|
|
39
|
-
|
|
40
|
-
<li><a href="#hello">Hello World</a></li>
|
|
41
|
-
<!-- <li><a href="#hello-pushstate">Hello World - Push State</a></li>
|
|
42
|
-
<li><a href="#hello-delayed">Hello World - Delayed</a></li>
|
|
43
|
-
<li><a href="#hello-directive">Hello World - Directive</a></li>
|
|
44
|
-
<li role="separator" class="divider"></li> -->
|
|
45
|
-
<li><a href="#counter">Simple Counter</a></li>
|
|
46
|
-
<li><a href="#counters">Multiple Counters</a></li>
|
|
47
|
-
<li role="separator" class="divider"></li>
|
|
48
|
-
<li><a href="#calculator">Calculator</a></li>
|
|
49
|
-
<li><a href="#dragdrop">Pointer</a></li>
|
|
50
|
-
<li><a href="#animation">Animation</a></li>
|
|
51
|
-
<li><a href="#svg">SVG</a></li>
|
|
52
|
-
<li><a href="#todo">Todo - Undo - Redo</a></li>
|
|
53
|
-
<li><a href="#webcomponents">Web-Components</a></li>
|
|
54
|
-
<li role="separator" class="divider"></li>
|
|
55
|
-
<li><a href="https://github.com/samphilipd/todomvc-apprun">ToDoMVC Example</a></li>
|
|
56
|
-
<li><a href="https://yysun.github.io/apprun-hn">Hacker News Reader - PWA Example</a></li>
|
|
57
|
-
<li><a href="https://github.com/gothinkster/apprun-realworld-example-app">RealWorld Example App</a></li>
|
|
58
|
-
<li><a href="https://github.com/yysun/apprun-apress-book">Examples from the Apress Book</a></li>
|
|
59
|
-
</ul>
|
|
60
|
-
</li>
|
|
61
|
-
<li class="dropdown">
|
|
62
|
-
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Benchmarks
|
|
63
|
-
<span class="caret"></span></a>
|
|
64
|
-
<ul class="dropdown-menu">
|
|
65
|
-
<li><a href="#benchmark">Benchmark JSX</a></li>
|
|
66
|
-
<li><a href="#benchmark-lit-html">Benchmark lit-html</a></li>
|
|
67
|
-
</ul>
|
|
68
|
-
</li>
|
|
69
|
-
<li><a href="https://github.com/yysun/apprun">Github</a></li>
|
|
70
|
-
</ul>
|
|
71
|
-
</div><!--/.nav-collapse -->
|
|
72
|
-
</div>
|
|
73
|
-
</nav>
|
|
74
|
-
|
|
75
|
-
<div class="container">
|
|
76
|
-
<div id="my-app"></div>
|
|
77
|
-
</div> <!-- /container -->
|
|
78
|
-
|
|
79
|
-
<script src="https://code.jquery.com/jquery-3.1.1.min.js"
|
|
80
|
-
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
|
|
81
|
-
|
|
82
|
-
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
|
|
83
|
-
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
|
84
|
-
|
|
85
|
-
<script src="demo/app.js"></script>
|
|
86
|
-
</body>
|
|
87
|
-
</html>
|
package/jest.config.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/** @type {import('jest').Config} */
|
|
2
|
-
module.exports = {
|
|
3
|
-
testEnvironment: "jsdom",
|
|
4
|
-
transformIgnorePatterns: [
|
|
5
|
-
"node_modules/(?!(lit|@lit|lit-html|@lit-labs|property-information))"
|
|
6
|
-
],
|
|
7
|
-
transform: {
|
|
8
|
-
"^.+\\.(t|j)sx?$": ["ts-jest", {
|
|
9
|
-
useESM: true,
|
|
10
|
-
tsconfig: "tsconfig.jest.json",
|
|
11
|
-
diagnostics: {
|
|
12
|
-
warnOnly: true, // Convert type-check errors to warnings during tests
|
|
13
|
-
ignoreCodes: [
|
|
14
|
-
"TS7006", // Parameter implicitly has an 'any' type
|
|
15
|
-
"TS7015", // Element implicitly has an 'any' type because index expression is not of type 'number'
|
|
16
|
-
"TS7031", // Binding element implicitly has an 'any' type
|
|
17
|
-
"TS7053", // Element implicitly has an 'any' type because expression of type can't be used to index type
|
|
18
|
-
"TS2683", // 'this' implicitly has type 'any' because it does not have a type annotation
|
|
19
|
-
"TS2345", // Argument of type is not assignable to parameter of type
|
|
20
|
-
"TS2322", // Type is not assignable to type
|
|
21
|
-
"TS18047", // Object is possibly 'null'
|
|
22
|
-
"TS18048" // Property is possibly 'undefined'
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
}]
|
|
26
|
-
},
|
|
27
|
-
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
|
|
28
|
-
moduleFileExtensions: [
|
|
29
|
-
"ts",
|
|
30
|
-
"tsx",
|
|
31
|
-
"js",
|
|
32
|
-
"jsx",
|
|
33
|
-
"json",
|
|
34
|
-
"node"
|
|
35
|
-
],
|
|
36
|
-
preset: "ts-jest/presets/default-esm",
|
|
37
|
-
extensionsToTreatAsEsm: [".ts", ".tsx"],
|
|
38
|
-
testEnvironmentOptions: {
|
|
39
|
-
url: "http://localhost"
|
|
40
|
-
},
|
|
41
|
-
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
|
|
42
|
-
moduleNameMapper: {
|
|
43
|
-
"^lit$": "<rootDir>/node_modules/lit/development/index.js",
|
|
44
|
-
"^lit/directive$": "<rootDir>/node_modules/lit/development/directive.js",
|
|
45
|
-
"^lit/directives/(.*)$": "<rootDir>/node_modules/lit/development/directives/$1",
|
|
46
|
-
"^property-information$": "<rootDir>/node_modules/property-information/index.js",
|
|
47
|
-
"^(\\.{1,2}/.*)\\.js$": "$1",
|
|
48
|
-
"^(\\.{1,2}/.*)\\.jsx?$": "$1",
|
|
49
|
-
"^(\\.{1,2}/.*)\\.tsx?$": "$1"
|
|
50
|
-
},
|
|
51
|
-
testPathIgnorePatterns: [
|
|
52
|
-
"/node_modules/",
|
|
53
|
-
"/dist/",
|
|
54
|
-
"/coverage/",
|
|
55
|
-
"/esm/"
|
|
56
|
-
]
|
|
57
|
-
};
|
package/jest.setup.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// Add Jest-specific test setup
|
|
2
|
-
global.spyOn = (obj, method) => {
|
|
3
|
-
const spy = jest.spyOn(obj, method);
|
|
4
|
-
spy.calls = {
|
|
5
|
-
allArgs: () => spy.mock.calls,
|
|
6
|
-
all: () => spy.mock.calls.map(args => ({ args })),
|
|
7
|
-
count: () => spy.mock.calls.length,
|
|
8
|
-
first: () => spy.mock.calls[0],
|
|
9
|
-
mostRecent: () => spy.mock.calls[spy.mock.calls.length - 1]
|
|
10
|
-
};
|
|
11
|
-
return spy;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// Add TextEncoder/TextDecoder polyfills for JSDOM environment
|
|
15
|
-
if (typeof TextEncoder === 'undefined') {
|
|
16
|
-
const { TextEncoder, TextDecoder } = require('util');
|
|
17
|
-
global.TextEncoder = TextEncoder;
|
|
18
|
-
global.TextDecoder = TextDecoder;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Ensure global references are properly set up for JSDOM
|
|
22
|
-
Object.defineProperty(global, 'Node', {
|
|
23
|
-
value: globalThis.Node || class Node { },
|
|
24
|
-
writable: true,
|
|
25
|
-
configurable: true
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
Object.defineProperty(global, 'HTMLElement', {
|
|
29
|
-
value: globalThis.HTMLElement || class HTMLElement { },
|
|
30
|
-
writable: true,
|
|
31
|
-
configurable: true
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
Object.defineProperty(global, 'SVGElement', {
|
|
35
|
-
value: globalThis.SVGElement || class SVGElement { },
|
|
36
|
-
writable: true,
|
|
37
|
-
configurable: true
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// Mock jasmine functionality with Jest equivalents
|
|
41
|
-
global.jasmine = {
|
|
42
|
-
createSpy: (name) => {
|
|
43
|
-
const spy = jest.fn();
|
|
44
|
-
spy.calls = {
|
|
45
|
-
allArgs: () => spy.mock.calls,
|
|
46
|
-
all: () => spy.mock.calls.map(args => ({ args })),
|
|
47
|
-
count: () => spy.mock.calls.length,
|
|
48
|
-
first: () => spy.mock.calls[0],
|
|
49
|
-
mostRecent: () => spy.mock.calls[spy.mock.calls.length - 1]
|
|
50
|
-
};
|
|
51
|
-
spy.and = {
|
|
52
|
-
callThrough: () => spy,
|
|
53
|
-
returnValue: (val) => spy.mockReturnValue(val),
|
|
54
|
-
callFake: (fn) => spy.mockImplementation(fn)
|
|
55
|
-
};
|
|
56
|
-
return spy;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
// Setup document if it doesn't exist (for JSDOM)
|
|
61
|
-
if (typeof document === 'undefined') {
|
|
62
|
-
global.document = {
|
|
63
|
-
createElement: () => ({
|
|
64
|
-
setAttribute: () => { },
|
|
65
|
-
style: {},
|
|
66
|
-
appendChild: () => { }
|
|
67
|
-
}),
|
|
68
|
-
createComment: () => ({}),
|
|
69
|
-
body: {
|
|
70
|
-
appendChild: () => { }
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
package/logo.png
DELETED
|
Binary file
|
package/react.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
const toReact = (componentClass) => {
|
|
4
|
-
const component = new componentClass().mount();
|
|
5
|
-
const { state, view } = component;
|
|
6
|
-
return () => {
|
|
7
|
-
const [_state, setState] = useState(state);
|
|
8
|
-
component.view = setState;
|
|
9
|
-
return view(_state);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default toReact;
|
package/rollup.config.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rollup Configuration
|
|
3
|
-
*
|
|
4
|
-
* This configuration builds AppRun's ESM bundles with the following features:
|
|
5
|
-
* - Minification (controlled by MINIFY env var, defaults to true)
|
|
6
|
-
* - Sourcemaps (enabled by default)
|
|
7
|
-
* - Property mangling for properties starting with '__'
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* - Default build (minified): rollup -c
|
|
11
|
-
* - Unminified build: MINIFY=false rollup -c
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const terser = require('@rollup/plugin-terser');
|
|
15
|
-
const resolve = require('@rollup/plugin-node-resolve');
|
|
16
|
-
const commonjs = require('@rollup/plugin-commonjs');
|
|
17
|
-
|
|
18
|
-
// Control minification via environment variable
|
|
19
|
-
const minify = process.env.MINIFY !== 'false';
|
|
20
|
-
|
|
21
|
-
const plugins = minify ? [
|
|
22
|
-
resolve(),
|
|
23
|
-
commonjs(),
|
|
24
|
-
terser({
|
|
25
|
-
module: true,
|
|
26
|
-
sourceMap: true, // Enable sourcemap support in terser
|
|
27
|
-
mangle: {
|
|
28
|
-
properties: {
|
|
29
|
-
regex: /^__/,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
})
|
|
33
|
-
] : [
|
|
34
|
-
resolve(),
|
|
35
|
-
commonjs()
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
module.exports = [{
|
|
39
|
-
input: 'esm/apprun.js',
|
|
40
|
-
output: {
|
|
41
|
-
file: 'dist/apprun.esm.js',
|
|
42
|
-
format: 'esm',
|
|
43
|
-
sourcemap: true
|
|
44
|
-
},
|
|
45
|
-
plugins,
|
|
46
|
-
}, {
|
|
47
|
-
input: 'esm/apprun-html.js',
|
|
48
|
-
output: {
|
|
49
|
-
file: 'dist/apprun-html.esm.js',
|
|
50
|
-
format: 'esm',
|
|
51
|
-
sourcemap: true
|
|
52
|
-
},
|
|
53
|
-
plugins
|
|
54
|
-
}, {
|
|
55
|
-
input: 'esm/apprun-play-html.js',
|
|
56
|
-
output: {
|
|
57
|
-
file: 'dist/apprun-play-html.esm.js',
|
|
58
|
-
format: 'esm',
|
|
59
|
-
sourcemap: true
|
|
60
|
-
},
|
|
61
|
-
plugins
|
|
62
|
-
}]
|
package/src/add-components.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { ComponentRoute, IApp } from './types';
|
|
2
|
-
import app from './app'; // ADD: Global app instance access
|
|
3
|
-
|
|
4
|
-
// Type guard functions using the enhanced type system
|
|
5
|
-
function isComponentInstance(obj: any): boolean {
|
|
6
|
-
return obj && typeof obj === 'object' && typeof obj.mount === 'function';
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function isComponentConstructor(fn: any): boolean {
|
|
10
|
-
return typeof fn === 'function' &&
|
|
11
|
-
fn.prototype &&
|
|
12
|
-
fn.prototype.constructor === fn &&
|
|
13
|
-
(fn.prototype.mount !== undefined ||
|
|
14
|
-
fn.prototype.state !== undefined ||
|
|
15
|
-
fn.prototype.view !== undefined);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function isFactoryFunction(fn: any): boolean {
|
|
19
|
-
return typeof fn === 'function' && !isComponentConstructor(fn);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Recursive function resolution with enhanced type checking
|
|
23
|
-
async function resolveComponent(component: any, maxDepth = 3): Promise<any> {
|
|
24
|
-
let resolved = component;
|
|
25
|
-
let depth = 0;
|
|
26
|
-
|
|
27
|
-
while (isFactoryFunction(resolved) && depth < maxDepth) {
|
|
28
|
-
try {
|
|
29
|
-
const result = await resolved();
|
|
30
|
-
if (result === resolved) break; // Prevent infinite loops
|
|
31
|
-
resolved = result;
|
|
32
|
-
depth++;
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error(`Error executing component function: ${error}`);
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return resolved;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export default async (element: HTMLElement | string, components: ComponentRoute) => {
|
|
43
|
-
for (const [route, component] of Object.entries(components)) {
|
|
44
|
-
if (!component || !route) {
|
|
45
|
-
console.error(`Invalid component configuration: component=${component}, route=${route}`);
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Check if it's a direct component instance
|
|
50
|
-
if (isComponentInstance(component)) {
|
|
51
|
-
const options = { route };
|
|
52
|
-
(component as any).mount(element, options);
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Check if it's a component class constructor
|
|
57
|
-
if (isComponentConstructor(component)) {
|
|
58
|
-
const instance = new (component as any)();
|
|
59
|
-
const options = { route };
|
|
60
|
-
instance.mount(element, options);
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// At this point it must be a function - resolve it
|
|
65
|
-
if (isFactoryFunction(component)) {
|
|
66
|
-
// Resolve the function to see what it returns
|
|
67
|
-
let resolved = await resolveComponent(component);
|
|
68
|
-
|
|
69
|
-
// Check if resolved result is a component instance
|
|
70
|
-
if (isComponentInstance(resolved)) {
|
|
71
|
-
const options = { route };
|
|
72
|
-
resolved.mount(element, options);
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Check if resolved result is a component constructor
|
|
77
|
-
if (isComponentConstructor(resolved)) {
|
|
78
|
-
const instance = new resolved();
|
|
79
|
-
const options = { route };
|
|
80
|
-
instance.mount(element, options);
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// If resolved result is still a function or anything else, treat original as event handler with render wrapper
|
|
85
|
-
app.on(route, (...args: any[]) => {
|
|
86
|
-
const result = (component as any)(...args);
|
|
87
|
-
if (typeof element === 'string') {
|
|
88
|
-
element = document.querySelector(element) as HTMLElement;
|
|
89
|
-
if (!element) {
|
|
90
|
-
console.error(`Element not found: ${element}`);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return (app as unknown as IApp).render(element, result);
|
|
95
|
-
});
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// If we get here, it's an invalid component type
|
|
100
|
-
console.error(`Invalid component: component must be a class, instance, or function that returns a class/instance`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|