Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Add DOM & EventTarget #10223

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*.launch
.settings/
*.sublime-workspace

results.md
# IDE - VSCode
.vscode/*
!.vscode/settings.json
Expand Down
13 changes: 13 additions & 0 deletions NativeScript.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"folders": [
{
"path": "."
},
{
"path": "../dominative"
},
{
"path": "../../apps/undom-ng"
}
]
}
1 change: 1 addition & 0 deletions apps/automated/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"version": "0.0.0",
"main": "src/main.ts",
"description": "NativeScript Application",
"license": "MIT",
Expand Down
7 changes: 6 additions & 1 deletion apps/automated/src/main-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ Trace.addCategories(Trace.categories.Test + ',' + Trace.categories.Error);
// ));

function runTests() {
setTimeout(() => tests.runAll(''), 10);
setTimeout(() => {
// Calling these two consectively causes a crash.
// Otherwise all tests are passing.
tests.runAll('TAB-VIEW-NAVIGATION');
tests.runAll('IMAGE');
}, 10);
}

export function onNavigatedTo(args) {
Expand Down
4 changes: 2 additions & 2 deletions apps/automated/src/ui/action-bar/action-bar-tests-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ export function test_ActionBarItemBindingToEvent() {
const actionBarItem = page.actionBar.actionItems.getItemAt(0);

TKUnit.assertEqual((<any>actionBarItem)._observers['tap'].length, 1, 'There should be only one listener');
TKUnit.assertEqual((<any>actionBarItem)._observers['tap'][0].callback + '', firstHandler.toString(), 'First handler is not equal');
TKUnit.assertEqual((<any>actionBarItem)._observers['tap'][0].listener + '', firstHandler.toString(), 'First handler is not equal');

p.bindingContext.set('test', secondHandler);

TKUnit.assertEqual((<any>actionBarItem)._observers['tap'].length, 1, 'There should be only one listener');
TKUnit.assertEqual((<any>actionBarItem)._observers['tap'][0].callback + '', secondHandler.toString(), 'Second handler is not equal');
TKUnit.assertEqual((<any>actionBarItem)._observers['tap'][0].listener + '', secondHandler.toString(), 'Second handler is not equal');
};

helper.navigate(function () {
Expand Down
9 changes: 6 additions & 3 deletions apps/toolbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
},
"dependencies": {
"@nativescript/core": "file:../../packages/core",
"nativescript-theme-core": "file:../../node_modules/nativescript-theme-core",
"@nativescript/imagepicker": "^1.0.6"
"@nativescript/imagepicker": "^1.0.6",
"benchmark": "^2.1.4",
"lodash": "^4.17.21",
"nativescript-theme-core": "file:../../node_modules/nativescript-theme-core"
},
"devDependencies": {
"@nativescript/android": "~8.4.0",
"@nativescript/ios": "~8.4.0",
"@nativescript/webpack": "file:../../dist/packages/nativescript-webpack.tgz",
"typescript": "~4.9.5"
"typescript": "~4.9.5",
"@types/benchmark": "2.1.2"
}
}
86 changes: 84 additions & 2 deletions apps/toolbox/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,85 @@
import { Application } from '@nativescript/core';
import { Application, FlexboxLayout, GridLayout } from '@nativescript/core';
import Benchmark from 'benchmark';
const suite = new Benchmark.Suite();

Application.run({ moduleName: 'app-root' });

//@ts-ignore
global.performance = {
now() {
if (global.android) {
return java.lang.System.nanoTime() / 1000000;
} else {
return CACurrentMediaTime();
}
},
};

//@ts-ignore
//registerElement('view-element', FlexboxLayout);

// declare global {
// interface HTMLElementTagNameMap {
// 'view-element': FlexboxLayout;
// }
// }

Application.run({
create: () => {
const root = new GridLayout();
const view = new FlexboxLayout();
//const element = document.createElement('view-element');
root.addChild(view);
//root.addChild(element);

for (let i = 0; i < 20; i++) {
//element.on('loaded', () => {});
view.on('loaded', () => {});
}
// Cache views to prevent GC from kicking in.
const views = [];
suite
.add('new FlexboxLayout()', () => {
views.push(new FlexboxLayout());
})
// .add('document.createElement', () => {
// document.createElement('view-element');
// })
.add('view.notify (20 Listeners)', () => {
view.notify({
eventName: 'loaded',
object: view,
});
})
// .add('element.dispatchEvent (20 Listeners)', () => {
// element.dispatchEvent(new Event('loaded'));
// })
.add('view.addChild (shallow)', () => {
view.addChild(new FlexboxLayout());
})
// .add('element.appendChild (shallow)', () => {
// element.appendChild(document.createElement('view-element'));
// })
.add('view.addChild (deep)', () => {
let current = view;
for (let i = 0; i < 3; i++) {
const child = new FlexboxLayout();
current.addChild(child);
current = child;
}
})
// .add('element.appendChild (deep)', () => {
// let current = element;
// for (let i = 0; i < 10; i++) {
// const child = document.createElement('view-element');
// current.appendChild(child);
// current = child;
// }
// })
.on('cycle', function (event) {
console.log(String(event.target));
})
.run({ async: true });

return root;
},
});
3 changes: 2 additions & 1 deletion apps/toolbox/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"diagnostics": false,
"paths": {
"~/*": ["src/*"]
}
},
"allowSyntheticDefaultImports": true
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
"eslint": "7.22.0",
"eslint-config-prettier": "^8.1.0",
"gonzales": "^1.0.7",
"html-entities": "^2.3.3",
"html-escaper": "3.0.3",
"husky": "^8.0.1",
"jest": "29.4.3",
"lint-staged": "^13.1.0",
Expand Down Expand Up @@ -73,4 +75,3 @@
]
}
}

1 change: 0 additions & 1 deletion packages/core/accessibility/font-scale.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ function setupConfigListener() {
if (configChangedCallback) {
return;
}

Application.off(Application.launchEvent, setupConfigListener);
const context = Application.android?.context as android.content.Context;
if (!context) {
Expand Down