Skip to content

Commit 226e399

Browse files
committed
progress (spec rewrite)
1 parent e344d18 commit 226e399

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1412
-1332
lines changed

examples/component-async.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
<body>
77
<script type='text/mask' data-run='true'>
88
h4 > 'User'
9-
:user-profile;
9+
UserProfile;
1010
</script>
1111

1212

1313
<script>
14-
mask.registerHandler(':user-profile', Compo({
14+
mask.registerHandler('UserProfile', mask.Compo({
1515
template: "input type='text' value='~[name]'",
1616

1717
onRenderStart: function(model, ctx){
1818
// Only this component is paused,
1919
// all sync components will still be renderd,
2020
// and other async components are loaded parallel
2121

22-
var resume = Compo.pause(this, ctx),
22+
var resume = mask.Compo.pause(this, ctx),
2323
profile = this;
2424

2525
// fake some async job for getting e.g. the model for the component

examples/component.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<script src='../lib/mask.js'></script>
3939
<script>
4040

41-
mask.registerHandler('UserProfile', Compo({
41+
mask.registerHandler('UserProfile', mask.Compo({
4242
template: document.querySelector('#user-template').textContent,
4343

4444
events: {
@@ -75,11 +75,11 @@
7575

7676
window.onload = function(){
7777

78-
var App = Compo({
78+
var App = mask.Compo({
7979
template: document.querySelector('#layout').textContent
8080
});
8181

82-
window.app = Compo.initialize(App, null, document.body);
82+
window.app = mask.Compo.initialize(App, null, document.body);
8383

8484
};
8585

examples/interpolation.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<script src='../lib/mask.js'></script>
4040
<script>
4141

42-
mask.registerHandler(':user', Compo({
42+
mask.registerHandler(':user', mask.Compo({
4343
tagName: 'div',
4444
scope: {
4545
userTitle: '"User" Component'

examples/simple.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<body>
44
<section class='foo'>
55
<script type='text/mask' data-run='true'>
6-
ul > for(flower of flowers) {
6+
ul > for (flower of flowers) {
77
li > '~[flower]'
88
}
99
</script>

projects/mask-compo/src/compo/CompoStatics.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,18 @@ import { Anchor } from './anchor'
1616
import { CompoConfig } from './CompoConfig'
1717
import { Pipes } from './pipes'
1818

19-
2019
import { Component } from './Component'
2120

2221
declare var include;
2322

2423
export const CompoStatics = {
2524

26-
create (){
25+
create (...args) {
2726
return compo_create(arguments as any);
2827
},
2928

3029
createClass (){
3130
throw Error('@Obsolete: createClass');
32-
var Ctor = compo_create(arguments as any),
33-
classProto = Ctor.prototype;
34-
classProto.Construct = Ctor;
35-
return Class(classProto);
3631
},
3732

3833
initialize (mix: string | Function | any, model?, ctx?, container?, parent?) {
@@ -43,7 +38,7 @@ export const CompoStatics = {
4338
if (ctx && ctx.nodeType != null){
4439
container = ctx;
4540
ctx = null;
46-
}else if (model && model.nodeType != null){
41+
} else if (model && model.nodeType != null){
4742
container = model;
4843
model = null;
4944
}

src/api/exports.ts

-1
This file was deleted.

src/feature/modules/Import/utils.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { u_resolvePathFromImport } from '../utils';
22
import { Endpoint } from '../class/Endpoint';
33
import { i_Types } from './ImportTypes'
4-
import { m_getType } from '../Module/exports';
4+
import { type_get } from '../types';
5+
56

67
export function i_createImport (node, ctx, ctr, module?) {
78
var path = u_resolvePathFromImport(node, ctx, ctr, module),
@@ -15,7 +16,7 @@ function create (endpoint, node, parent){
1516
};
1617

1718
function Factory(endpoint) {
18-
var type = m_getType(endpoint);
19+
var type = type_get(endpoint);
1920
var Ctor = i_Types[type];
2021
if (Ctor == null) {
2122
throw Error('Module is not supported for type ' + type + ' and the path ' + endpoint.path);

src/feature/modules/Module/Module.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { fn_doNothing } from '@utils/fn';
22
import { obj_getProperty } from '@utils/obj';
3-
import { path_getDir } from '@core/util/path';
43
import { class_create } from '@utils/class';
54
import { class_Dfr } from '@utils/class/Dfr';
5+
import { path_getDir } from '@core/util/path';
66
import { u_isNpmPath, u_resolveNpmPath } from '../utils';
7-
import { m_getModuleType } from './utils';
87

98
export const IModule = class_create(class_Dfr, {
109
type: null,
@@ -41,15 +40,12 @@ export const IModule = class_create(class_Dfr, {
4140
return this;
4241
},
4342
doLoad: function(){
44-
var self = this;
4543
this
46-
.load_(this.path)
47-
.fail(function(err){
48-
self.onLoadError_(err);
49-
})
50-
.done(function(mix){
51-
self.onLoadSuccess_(mix);
52-
});
44+
.load_(this.path)
45+
.then(
46+
mix => this.onLoadSuccess_(mix),
47+
err => this.onLoadError_(err)
48+
);
5349
},
5450
complete_: function(error, exports){
5551
this.exports = exports;
+14-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
import { m_Types } from './ModuleTypes';
21
import { class_create } from '@utils/class';
32
import { parser_parseHtml } from '@core/parser/exports';
3+
import { m_Types } from './ModuleTypes';
44
import { ModuleMask } from './ModuleMask';
55

6+
67
export const ModuleHtml = m_Types['html'] = class_create(ModuleMask, {
7-
type: 'mask',
8-
preprocess_: function(mix, next) {
9-
var ast = typeof mix === 'string'
10-
? parser_parseHtml(mix)
11-
: mix
12-
;
13-
return ModuleMask
14-
.prototype
15-
.preprocess_
16-
.call(this, ast, next);
17-
}
18-
});
8+
type: 'mask',
9+
preprocess_ (mix, next) {
10+
var ast = typeof mix === 'string'
11+
? parser_parseHtml(mix)
12+
: mix
13+
;
14+
return ModuleMask
15+
.prototype
16+
.preprocess_
17+
.call(this, ast, next);
18+
}
19+
});

0 commit comments

Comments
 (0)