Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a2d23ae

Browse files
committed
Glimmer 0.7.2
1 parent c6c6626 commit a2d23ae

File tree

22 files changed

+404
-0
lines changed

22 files changed

+404
-0
lines changed

glimmer-v0.7.2-keyed/.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
8+
[*]
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true
13+
indent_style = space
14+
indent_size = 2
15+
16+
[*.hbs]
17+
insert_final_newline = false
18+
19+
[*.{diff,md}]
20+
trim_trailing_whitespace = false

glimmer-v0.7.2-keyed/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
tmp/*
3+
dist

glimmer-v0.7.2-keyed/.watchmanconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ignore_dirs": ["tmp", "dist"]
3+
}

glimmer-v0.7.2-keyed/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# glimmer-app
2+
3+
This README outlines the details of collaborating on this Glimmer application.
4+
A short introduction of this app could easily go here.
5+
6+
## Prerequisites
7+
8+
You will need the following things properly installed on your computer.
9+
10+
* [Git](https://git-scm.com/)
11+
* [Node.js](https://nodejs.org/) (with NPM)
12+
* [Yarn](https://yarnpkg.com/en/)
13+
* [Ember CLI](https://ember-cli.com/)
14+
15+
## Installation
16+
17+
* `git clone <repository-url>` this repository
18+
* `cd glimmer-app`
19+
* `yarn`
20+
21+
## Running / Development
22+
23+
* `ember serve`
24+
* Visit your app at [http://localhost:4200](http://localhost:4200).
25+
26+
### Building
27+
28+
* `ember build` (development)
29+
* `ember build --environment production` (production)
30+
31+
## Further Reading / Useful Links
32+
33+
* [glimmerjs](http://github.com/tildeio/glimmer/)
34+
* [ember-cli](https://ember-cli.com/)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
module.exports = function(environment) {
4+
let ENV = {
5+
modulePrefix: 'glimmer-app',
6+
environment: environment
7+
};
8+
9+
return ENV;
10+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* This is just a placeholder file to keep TypeScript aware editors happy. At build time,
3+
* it will be replaced with a complete map of resolvable module paths => rolled up contents.
4+
*/
5+
6+
export interface Dict<T> {
7+
[index: string]: T;
8+
}
9+
10+
declare let map: Dict<any>;
11+
export default map;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* This is just a placeholder file to keep TypeScript aware editors happy. At build time,
3+
* it will be replaced with a resolver configuration composed from your application's
4+
* `config/environment.js` (and supplemented with default settings as possible).
5+
*/
6+
7+
import { ResolverConfiguration } from '@glimmer/resolver';
8+
declare var _default: ResolverConfiguration;
9+
export default _default;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
let browsers = [
2+
'last 1 Chrome versions'
3+
];
4+
5+
if (process.env.EMBER_ENV === 'test') {
6+
browsers = [
7+
'last 1 Chrome versions',
8+
'last 1 Firefox versions'
9+
];
10+
}
11+
12+
module.exports = { browsers };
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
const GlimmerApp = require('@glimmer/application-pipeline').GlimmerApp;
4+
5+
module.exports = function(defaults) {
6+
let app = new GlimmerApp(defaults, {
7+
// Add options here
8+
fingerprint: {
9+
enabled: false
10+
}
11+
});
12+
13+
return app.toTree();
14+
};

glimmer-v0.7.2-keyed/package.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "glimmer-app",
3+
"version": "0.0.0",
4+
"description": "A brand new Glimmer app.",
5+
"directories": {
6+
"doc": "doc",
7+
"test": "tests"
8+
},
9+
"scripts": {
10+
"build": "ember build -e production",
11+
"start": "ember server",
12+
"test": "ember test",
13+
"build-dev": "ember build",
14+
"build-prod": "ember build --environment=production"
15+
},
16+
"devDependencies": {
17+
"@glimmer/application": "^0.7.2",
18+
"@glimmer/application-pipeline": "^0.8.0",
19+
"@glimmer/blueprint": "^0.5.0",
20+
"@glimmer/inline-precompile": "^1.0.0",
21+
"@glimmer/resolver": "^0.3.0",
22+
"@glimmer/test-helpers": "^0.30.0",
23+
"@types/qunit": "^2.0.31",
24+
"broccoli-asset-rev": "^2.5.0",
25+
"ember-cli": "^2.14.0",
26+
"ember-cli-dependency-checker": "^2.0.1",
27+
"ember-cli-inject-live-reload": "^1.6.1",
28+
"ember-cli-sass": "^6.2.0",
29+
"ember-cli-uglify": "^2.0.0-beta.1",
30+
"qunitjs": "^2.3.3",
31+
"typescript": "^2.2.2"
32+
},
33+
"engines": {
34+
"node": ">= 4.0"
35+
},
36+
"private": true
37+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# http://www.robotstxt.org
2+
User-agent: *
3+
Disallow:

glimmer-v0.7.2-keyed/src/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import App from './main';
2+
import { ComponentManager, setPropertyDidChange } from '@glimmer/component';
3+
4+
const app = new App();
5+
const containerElement = document.getElementById('app');
6+
7+
setPropertyDidChange(() => {
8+
app.scheduleRerender();
9+
});
10+
11+
app.registerInitializer({
12+
initialize(registry) {
13+
registry.register(`component-manager:/${app.rootName}/component-managers/main`, ComponentManager);
14+
}
15+
});
16+
17+
app.renderComponent('my-table', containerElement, null);
18+
19+
app.boot();

glimmer-v0.7.2-keyed/src/main.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Application from '@glimmer/application';
2+
import Resolver, { BasicModuleRegistry } from '@glimmer/resolver';
3+
import moduleMap from '../config/module-map';
4+
import resolverConfiguration from '../config/resolver-configuration';
5+
6+
export default class App extends Application {
7+
constructor() {
8+
let moduleRegistry = new BasicModuleRegistry(moduleMap);
9+
let resolver = new Resolver(resolverConfiguration, moduleRegistry);
10+
11+
super({
12+
rootName: resolverConfiguration.app.rootName,
13+
resolver
14+
});
15+
}
16+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function _ifEq([testA, testB, truthy]) {
2+
return ((testA === testB) ? truthy : '');
3+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import Component, { tracked } from "@glimmer/component";
2+
3+
function _random(max) {
4+
return Math.round(Math.random() * 1000) % max;
5+
}
6+
7+
let startTime;
8+
let lastMeasure;
9+
let startMeasure = function(name) {
10+
startTime = performance.now();
11+
lastMeasure = name;
12+
}
13+
let stopMeasure = function() {
14+
let last = lastMeasure;
15+
if (lastMeasure) {
16+
window.setTimeout(function () {
17+
lastMeasure = null;
18+
let stop = performance.now();
19+
let duration = 0;
20+
console.log(last+" took "+(stop-startTime));
21+
}, 0);
22+
}
23+
}
24+
25+
export default class Glimmerjs extends Component {
26+
maxId = 1;
27+
@tracked rows = {
28+
selected: undefined,
29+
data: []
30+
}
31+
32+
buildData(count = 1000) {
33+
let adjectives = ["pretty", "large", "big", "small", "tall", "short", "long", "handsome", "plain", "quaint", "clean", "elegant", "easy", "angry", "crazy", "helpful", "mushy", "odd", "unsightly", "adorable", "important", "inexpensive", "cheap", "expensive", "fancy"];
34+
let colours = ["red", "yellow", "blue", "green", "pink", "brown", "purple", "brown", "white", "black", "orange"];
35+
let nouns = ["table", "chair", "house", "bbq", "desk", "car", "pony", "cookie", "sandwich", "burger", "pizza", "mouse", "keyboard"];
36+
let data = [];
37+
for (let i = 0; i < count; i++) {
38+
data.push({ id: this.maxId++, label: adjectives[_random(adjectives.length)] + " " + colours[_random(colours.length)] + " " + nouns[_random(nouns.length)] });
39+
}
40+
return data;
41+
}
42+
43+
run() {
44+
startMeasure("run");
45+
this.rows = { selected: undefined, data: this.buildData(1000) };
46+
stopMeasure();
47+
}
48+
49+
runLots() {
50+
startMeasure("runLots");
51+
this.rows = { selected: undefined, data: this.buildData(10000) };
52+
stopMeasure();
53+
}
54+
55+
add() {
56+
startMeasure("add");
57+
this.rows = { ...this.rows, data: this.rows.data.concat(this.buildData(1000)) };
58+
stopMeasure();
59+
}
60+
61+
update() {
62+
startMeasure("update");
63+
let data = this.rows.data.map((item, index) => {
64+
if (index % 10 === 0) {
65+
return { ...item, label: `${item.label} !!!` };
66+
}
67+
return item;
68+
});
69+
this.rows = { ...this.rows, data }
70+
stopMeasure();
71+
}
72+
73+
clear() {
74+
startMeasure("clear");
75+
this.rows = { selected: undefined, data: [] }
76+
stopMeasure();
77+
}
78+
79+
swapRows() {
80+
startMeasure("swapRows");
81+
if(this.rows.data.length > 10) {
82+
let data = this.rows.data;
83+
let d4 = data[4];
84+
data[4] = data[9];
85+
data[9] = d4;
86+
this.rows = { ...this.rows, data }
87+
}
88+
stopMeasure();
89+
}
90+
91+
select(id) {
92+
startMeasure("select");
93+
this.rows = { ...this.rows, selected: id }
94+
stopMeasure();
95+
}
96+
97+
delete(id) {
98+
startMeasure("delete");
99+
let idx = this.rows.data.findIndex(item => item.id === id);
100+
let data = this.rows.data;
101+
data.splice(idx, 1);
102+
this.rows = { selected: undefined, data };
103+
stopMeasure();
104+
}
105+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<div class="jumbotron">
2+
<div class="row">
3+
<div class="col-md-6">
4+
<h1>Glimmer 0.7.2</h1>
5+
</div>
6+
<div class="col-md-6">
7+
<div class="row">
8+
<div class="col-sm-6 smallpad">
9+
<button type="button" class="btn btn-primary btn-block" id="run" onclick={{action run}}>Create 1,000 rows</button>
10+
</div>
11+
<div class="col-sm-6 smallpad">
12+
<button type="button" class="btn btn-primary btn-block" id="runlots" onclick={{action runLots}}>Create 10,000 rows</button>
13+
</div>
14+
<div class="col-sm-6 smallpad">
15+
<button type="button" class="btn btn-primary btn-block" id="add" onclick={{action add}}>Append 1,000 rows</button>
16+
</div>
17+
<div class="col-sm-6 smallpad">
18+
<button type="button" class="btn btn-primary btn-block" id="update" onclick={{action update}}>Update every 10th row</button>
19+
</div>
20+
<div class="col-sm-6 smallpad">
21+
<button type="button" class="btn btn-primary btn-block" id="clear" onclick={{action clear}}>Clear</button>
22+
</div>
23+
<div class="col-sm-6 smallpad">
24+
<button type="button" class="btn btn-primary btn-block" id="swaprows" onclick={{action swapRows}}>Swap Rows</button>
25+
</div>
26+
</div>
27+
</div>
28+
</div>
29+
</div>
30+
<table class="table table-hover table-striped test-data">
31+
<tbody>
32+
{{#each rows.data key="id" as |row|}}
33+
<tr class={{if-eq row.id rows.selected 'danger'}}>
34+
<td class="col-md-1">{{row.id}}</td>
35+
<td class="col-md-4">
36+
<a onclick={{action select row.id}}>{{row.label}}</a>
37+
</td>
38+
<td class="col-md-1"><a onclick={{action delete row.id}}><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></td>
39+
<td class="col-md-6"></td>
40+
</tr>
41+
{{/each}}
42+
</tbody>
43+
</table>
44+
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true"></span>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>Hello Glimmer</title>
7+
<meta name="description" content="">
8+
<meta name="viewport" content="width=device-width, initial-scale=1">
9+
10+
{{content-for "head"}}
11+
12+
<!-- <link rel="stylesheet" href="{{rootURL}}app.css"> -->
13+
<link rel="stylesheet" href="/css/currentStyle.css">
14+
15+
{{content-for "head-footer"}}
16+
</head>
17+
<body>
18+
{{content-for "body"}}
19+
20+
<div id="app" class="container"></div>
21+
<script src="{{rootURL}}app.js"></script>
22+
23+
{{content-for "body-footer"}}
24+
</body>
25+
</html>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
h1 {
2+
color: #444;
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { setApp, start } from '@glimmer/test-helpers';
2+
import App from '../../main';
3+
4+
QUnit.config.autostart = false;
5+
setApp(App);
6+
import '../../../tests';
7+
start();

0 commit comments

Comments
 (0)