Skip to content

Commit a255500

Browse files
author
dmp42
committed
Backport and tweaks
1 parent 2d67af0 commit a255500

File tree

4 files changed

+49
-216
lines changed

4 files changed

+49
-216
lines changed

package-dmp-darwin.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
{
22
"config": {
33
"self": "//static.loft.sn.ackitup.net:4242/lib/webitup"
4+
},
5+
6+
"directories": {
7+
"src": "src",
8+
"tests": "src/tests",
9+
"build": ".build",
10+
"tmp": ".tmp",
11+
"doc": "doc",
12+
"dist": "~/dev/projects/roxee/roxee/dependencies/jsboot/master/"
413
}
514
}

pukefile.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def build():
8888

8989
# There is only
9090
spitfireList = [
91+
'src/strict.js',
9192
'dependencies/spitfire/%s/spitfire-labjs.js' % spitversion,
9293
'src/onegateisopening/boot.js',
9394
'src/gister/packman.js'
@@ -105,6 +106,7 @@ def build():
105106

106107
postmessageshim = 'src/mingus/postmessage.js'
107108
gateList = [
109+
'src/strict.js',
108110
'dependencies/spitfire/%s/spitfire-labjs.js' % spitversion,
109111
postmessageshim,
110112
'src/onegateisopening/gate.js'
@@ -126,7 +128,6 @@ def build():
126128
# ================================
127129

128130
mingusList = [
129-
"src/strict.js",
130131
# Have postmessage shit
131132
postmessageshim,
132133
# Better safe than sorry - always include that
@@ -238,8 +239,8 @@ def deploy():
238239
# Libraries usually have a versioned path (True)
239240
# help.deployer(True)
240241
# Sites or apps dont
241-
help.deployer(Yak.paths['build'], True)
242+
help.deployer(Yak.paths['build'], False)
242243
# In case you wanna deploy dependencies as well
243244
p = 'dependencies/spitfire/%s/burnscars' % spitversion
244-
help.deployer(p, True, 'burnscars')
245+
help.deployer(p, False, 'burnscars')
245246

src/gister/packman.js

Lines changed: 35 additions & 212 deletions
Original file line numberDiff line numberDiff line change
@@ -7,68 +7,14 @@
77
*
88
* @license {PUKE-RIGHTS-LICENSE}.
99
* @copyright {PUKE-RIGHTS-COPYRIGHT}
10-
* @name {PUKE-GIT-ROOT}/jsboot/gister/packman.js{PUKE-GIT-REVISION}
10+
* @name {PUKE-GIT-ROOT}/gister/packman.js{PUKE-GIT-REVISION}
1111
*/
1212

13-
14-
// Guarantee that require is here
15-
16-
/*
17-
Inline module declarations
18-
19-
// Define sources
20-
gister.module('Bar').at('bar.js');
21-
gister.module('Foo').at('foo.js');
22-
23-
Modules can be declared inline:
24-
25-
gister.module('Foo', function() {
26-
export let x = 42;
27-
});
28-
29-
gister.import('bar.js').as('Bar');
30-
gister.import({'y': 'localName'}).from('Bar');
31-
gister.import('y').from("bar.js");
32-
33-
External module load
34-
35-
Modules can be loaded from external resources:
36-
37-
// Variant A: import URL syntax
38-
39-
// Variant B: module = syntax
40-
It is not necessary to bind a module to a local name, if the programmer simply wishes to import
41-
directly from the module:
42-
43-
*/
44-
45-
46-
/*
47-
gister.use('Module').as('Toto').from('Thing');
48-
gister.use('Module').as('Toto').from('Thing');
49-
gister.add('Toto1234').as('TotoVariableName');
50-
gister.pack('Stuffy.Thing', function(){
51-
});
52-
53-
54-
define = function(name, deps, callback) {
55-
require = req = function(deps, callback, relName, forceSync, alt) {
56-
57-
*/
58-
5913
/*global window*/
6014

61-
if (typeof jsBoot == 'undefined')
62-
var jsBoot = {};
63-
6415
(function(globalObject) {
6516
'use strict';
6617

67-
// Adapted from JSON3 (credit Oyvind Sean Kinsey)
68-
// Detect the "define" function exposed by asynchronous module loaders
69-
// var isLoader = typeof define === 'function' && define.amd;
70-
// var internalObj = typeof exports == 'object' && exports;
71-
7218
var toUse = [];
7319
var lastUse;
7420
var toAdd = [];
@@ -81,41 +27,17 @@ if (typeof jsBoot == 'undefined')
8127
}
8228
if (lastAdd) {
8329
if (!lastAdd.name)
84-
throw new Error('NEED_A_NAME', 'Trying to bind something without name');
30+
throw new Error('NEED_A_NAME: Trying to bind "something" without any name');
8531
toAdd.push(lastAdd);
8632
lastAdd = null;
8733
}
8834
};
8935

90-
this.use = function(a, optional) {
91-
flush();
92-
lastUse = {module: a, name: a.split('.').pop(), optional: optional};
93-
return this;
94-
};
95-
96-
this.add = function(a, optional) {
97-
if ((a === undefined) && !optional)
98-
throw new Error('UNDEFINED', 'Requesting something local that is undefined');
99-
flush();
100-
lastAdd = {value: a};
101-
return this;
102-
};
103-
104-
this.as = function(a) {
105-
if (lastUse)
106-
lastUse.name = a;
107-
else if (lastAdd)
108-
lastAdd.name = a;
109-
flush();
110-
};
111-
112-
113-
11436
var simplePull = function(glob, name, optional) {
11537
name.split('.').forEach(function(fragment) {
11638
if (!glob || !(fragment in glob))
11739
if (!optional)
118-
throw new Error('MISSING', 'Trying to require something that doesn\'t exist: ' + name);
40+
throw new Error('MISSING: Trying to require something that doesn\'t exist' + name);
11941
else
12042
return (glob = undefined);
12143
glob = glob[fragment];
@@ -135,9 +57,7 @@ if (typeof jsBoot == 'undefined')
13557
return ret;
13658
};
13759

138-
// var amdHack = {};
139-
140-
this.pack = function(name, factory) {
60+
var packer = function() {
14161
// Close anything going on
14262
flush();
14363
// Dereference requested stuff and flush it
@@ -150,149 +70,52 @@ if (typeof jsBoot == 'undefined')
15070
var api = {};
15171
localAdd.forEach(function(item) {
15272
if (item.name in api)
153-
throw new Error('ALREADY_DEFINED', 'You are shadowing ' + api[item.name] + ' with ' +
73+
throw new Error('ALREADY_DEFINED: You are shadowing ' + api[item.name] + ' with ' +
15474
item + ' for name ' + item.name);
15575
api[item.name] = item.value;
15676
});
15777

158-
// If AMD pattern
159-
/*
160-
if (isLoader || internalObj) {
161-
// Get dependencies names
162-
var deps = [];
163-
var udeps = [];
164-
var localNames = [];
165-
localUse.forEach(function(item) {
166-
var k = item.module.replace(/\./g, '/').split('/');
167-
var rest = [];
168-
while(!(k.join('/') in amdHack) && k.length){
169-
rest.unshift(k.pop());
170-
console.warn("******** unshifting", JSON.stringify(rest));
171-
}
172-
if(!k.length)
173-
throw new Error('UNRESOLVED', 'Requested dep doesnt pan out');
174-
deps.push(k.join('/'));
175-
udeps.push(rest);
176-
177-
localNames.push(item.name);
178-
});
179-
180-
// Fuck the identifier as well AMD style
181-
name = name.replace(/\./g, '/');
182-
// deps.unshift(name);
183-
184-
if (isLoader) {
185-
var module;
186-
var there = (name in amdHack);
187-
amdHack[name] = module = there ? amdHack[name] : {};
188-
if(!there){
189-
console.warn("defininnnnnnnnng", name);
190-
define(name, amdHack[name]);
191-
}
192-
193-
console.warn("getting", JSON.stringify(deps), JSON.stringify(udeps));
194-
require(deps, function(){
195-
console.warn("Actually defining/requiring with no name", name);
196-
var args = Array.prototype.slice.call(arguments);
197-
localNames.forEach(function(key, idx){
198-
if (key in api)
199-
throw new Error('ALREADY_DEFINED', 'You are shadowing ' + key);
200-
api[key] = args.shift();
201-
while(udeps[idx].length){
202-
console.warn("----------> raising the bar");
203-
api[key] = api[key][udeps[idx].shift()];
204-
}
205-
if(api[key] === undefined)
206-
throw new Error('MISSING', 'Trying to require something that doesn\'t exist');
207-
});
208-
// udeps
209-
console.warn("getting udeps", udeps);
210-
211-
var sub = {};
212-
sub = factory.apply(sub, [api]) || sub;
213-
Object.keys(sub).forEach(function(key){
214-
module[key] = sub[key];
215-
define(name + '/' + key, module[key]);
216-
});
217-
});
218-
219-
// require(deps, function(mod){
220-
// var module = mod || {};
221-
// var args = Array.prototype.slice.call(arguments, 1);
222-
// localNames.forEach(function(key){
223-
// if (key in api)
224-
// throw new Error('ALREADY_DEFINED', 'You are shadowing ' + key);
225-
// api[key] = args.shift();
226-
// if(api[key] === undefined)
227-
// throw new Error('MISSING', 'Trying to require something that doesn\'t exist');
228-
// });
229-
// console.warn("requiring", name, mod, api);
230-
231-
// factory.apply(module, [api]) || module;
232-
// });
233-
234-
}
235-
}else{*/
23678
localUse.forEach(function(item) {
23779
if (item.name in api)
238-
throw new Error('ALREADY_DEFINED', 'You are shadowing name ' + item.name);
80+
throw new Error('ALREADY_DEFINED: You are shadowing name ' + item.name);
23981
api[item.name] = simplePull(globalObject, item.module, item.optional);
24082
});
83+
return api;
84+
};
24185

242-
var r = parentPull(globalObject, name);
243-
r.o[r.k] = factory.apply(r.o[r.k], [api]) || r.o[r.k];
244-
// }
86+
this.use = function(a, optional) {
87+
flush();
88+
lastUse = {module: a, name: a.split('.').pop(), optional: optional};
89+
return this;
24590
};
24691

247-
this.run = function(factory) {
248-
// Close anything going on
92+
this.add = function(a, optional) {
93+
if ((a === undefined) && !optional)
94+
throw new Error('UNDEFINED: Requesting something local that is undefined');
24995
flush();
250-
// Dereference requested stuff and flush it
251-
var localUse = toUse;
252-
var localAdd = toAdd;
253-
toUse = [];
254-
toAdd = [];
96+
lastAdd = {value: a};
97+
return this;
98+
};
25599

256-
// Add local elements to the API
257-
var api = {};
258-
localAdd.forEach(function(item) {
259-
if (item.name in api)
260-
throw new Error('ALREADY_DEFINED', 'You are shadowing ' + item.name);
261-
api[item.name] = item.value;
262-
});
100+
this.as = function(a) {
101+
if (lastUse)
102+
lastUse.name = a;
103+
else if (lastAdd)
104+
lastAdd.name = a;
105+
flush();
106+
};
263107

264-
// If AMD pattern
265-
/* if (isLoader || internalObj) {
266-
// Get dependencies names
267-
var deps = localUse.map(function(item) {
268-
return item.module.replace(/\./g, '/');
269-
});
270-
var localNames = localUse.map(function(item) {
271-
return item.name;
272-
});
273-
if (isLoader) {
274-
require(deps, function(){
275-
var args = Array.prototype.slice.call(arguments);
276-
localNames.forEach(function(key){
277-
if (key in api)
278-
throw new Error('ALREADY_DEFINED', 'You are shadowing ' + key);
279-
api[key] = args.shift();
280-
if(api[key] === undefined)
281-
throw new Error('MISSING', 'Trying to require something that doesn\'t exist');
282-
});
283-
factory.apply({}, [api]);
284-
});
285-
}
286-
// Regular pattern
287-
} else {*/
288-
localUse.forEach(function(item) {
289-
if (item.name in api)
290-
throw new Error('ALREADY_DEFINED', 'You are shadowing ' + item.name);
291-
api[item.name] = simplePull(globalObject, item.module, item.optional);
292-
});
108+
this.pack = function(name, factory) {
109+
var api = packer();
110+
var r = parentPull(globalObject, name);
111+
var ret = factory.apply(r.o[r.k], [api]);
112+
if (ret)
113+
r.o[r.k] = ret;
114+
};
293115

116+
this.run = function(factory) {
117+
var api = packer();
294118
factory.apply({}, [api]);
295-
// }
296119
};
297-
}).apply(jsBoot, [window]);
298120

121+
}).apply(jsBoot, [window]);

src/jsboot/core/error.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jsBoot.pack('jsBoot.core', function(api) {
3232
this.stack = b.stack;
3333
this.name = name;
3434
if (!this.stack)
35-
this.stack = (typeof 'printStackTrace' != 'undefined') ? printStackTrace() : [];
35+
this.stack = (typeof printStackTrace != 'undefined') ? printStackTrace() : [];
3636
};
3737

3838
Object.getOwnPropertyNames(api.NativeError.prototype).forEach(function(i) {

0 commit comments

Comments
 (0)