Skip to content

Commit e8cb3fe

Browse files
committed
feature(dist): updating distributables to version 0.9.1
1 parent 55d8d3f commit e8cb3fe

File tree

4 files changed

+276
-186
lines changed

4 files changed

+276
-186
lines changed

dist/sass.js

Lines changed: 173 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,174 +1,202 @@
1-
/*! sass.js - v0.9.0 (59917af) - built 2015-05-21
1+
/*! sass.js - v0.9.1 (55d8d3f) - built 2015-05-30
22
providing libsass 3.2.4 (a6482aa)
33
via emscripten 1.32.4 (ae2f801)
44
*/
5+
56
(function (root, factory) {
67
'use strict';
78
if (typeof define === 'function' && define.amd) {
8-
// AMD. Register as an anonymous module.
99
define([], factory);
1010
} else if (typeof exports === 'object') {
11-
// Node. Does not work with strict CommonJS, but
12-
// only CommonJS-like enviroments that support module.exports,
13-
// like Node.
1411
module.exports = factory();
1512
} else {
16-
// Browser globals (root is window)
1713
root.Sass = factory();
1814
}
19-
}(this, function () {
15+
}(this, function () {/*global document*/
16+
// identify the path sass.js is located at in case we're loaded by a simple
17+
// <script src="path/to/sass.js"></script>
18+
// this path can be used to identify the location of
19+
// * sass.worker.js from sass.js
20+
// * libsass.js.mem from sass.sync.js
21+
// see https://github.com/medialize/sass.js/pull/32#issuecomment-103142214
22+
// see https://github.com/medialize/sass.js/issues/33
23+
var SASSJS_RELATIVE_PATH = (function() {
2024
'use strict';
21-
/*global Worker*/
22-
23-
var noop = function(){};
24-
var slice = [].slice;
25-
// defined upon first Sass.initialize() call
26-
var globalWorkerUrl;
27-
28-
function Sass(workerUrl) {
29-
if (!workerUrl && !globalWorkerUrl) {
30-
throw new Error(
31-
'Sass needs to be initialized with the URL of sass.worker.js - '
32-
+ 'either via Sass.setWorkerUrl(url) or by new Sass(url)'
33-
);
34-
}
3525

36-
if (!globalWorkerUrl) {
37-
globalWorkerUrl = workerUrl;
38-
}
26+
// in Node things are rather simple
27+
if (typeof __dirname !== 'undefined') {
28+
return __dirname;
29+
}
3930

40-
// bind all functions
41-
// we're doing this because we used to have a single hard-wired instance that allowed
42-
// [].map(Sass.removeFile) and we need to maintain that for now (at least until 1.0.0)
43-
for (var key in this) {
44-
if (typeof this[key] === 'function') {
45-
this[key] = this[key].bind(this);
46-
}
47-
}
31+
// we can only run this test in the browser,
32+
// so make sure we actually have a DOM to work with.
33+
if (typeof document === 'undefined' || !document.getElementsByTagName) {
34+
return null;
35+
}
4836

49-
this._callbacks = {};
50-
this._worker = new Worker(workerUrl || globalWorkerUrl);
51-
this._worker.addEventListener('message', this._handleWorkerMessage, false);
37+
// http://www.2ality.com/2014/05/current-script.html
38+
var currentScript = document.currentScript || (function() {
39+
var scripts = document.getElementsByTagName('script');
40+
return scripts[scripts.length - 1];
41+
})();
42+
43+
var path = currentScript && currentScript.src;
44+
if (!path) {
45+
return null;
5246
}
5347

54-
// allow setting the workerUrl before the first Sass instance is initialized,
55-
// where registering the global workerUrl would've happened automatically
56-
Sass.setWorkerUrl = function(workerUrl) {
48+
// [worker] make sure we're not running in some concatenated thing
49+
if (path.slice(-8) === '/sass.js') {
50+
return path.slice(0, -8);
51+
}
52+
53+
// [sync] make sure we're not running in some concatenated thing
54+
if (path.slice(-13) === '/sass.sync.js') {
55+
return path.slice(0, -13);
56+
}
57+
58+
return null;
59+
})() || '.';
60+
61+
/*global Worker, SASSJS_RELATIVE_PATH*/
62+
'use strict';
63+
64+
var noop = function(){};
65+
var slice = [].slice;
66+
// defined upon first Sass.initialize() call
67+
var globalWorkerUrl;
68+
69+
function Sass(workerUrl) {
70+
if (!workerUrl && !globalWorkerUrl) {
71+
/*jshint laxbreak:true */
72+
throw new Error(
73+
'Sass needs to be initialized with the URL of sass.worker.js - '
74+
+ 'either via Sass.setWorkerUrl(url) or by new Sass(url)'
75+
);
76+
/*jshint laxbreak:false */
77+
}
78+
79+
if (!globalWorkerUrl) {
5780
globalWorkerUrl = workerUrl;
58-
};
81+
}
5982

60-
Sass.style = {
61-
nested: 0,
62-
expanded: 1,
63-
compact: 2,
64-
compressed: 3
65-
};
83+
// bind all functions
84+
// we're doing this because we used to have a single hard-wired instance that allowed
85+
// [].map(Sass.removeFile) and we need to maintain that for now (at least until 1.0.0)
86+
for (var key in this) {
87+
if (typeof this[key] === 'function') {
88+
this[key] = this[key].bind(this);
89+
}
90+
}
6691

67-
Sass.comments = {
68-
'none': 0,
69-
'default': 1
70-
};
92+
this._callbacks = {};
93+
this._worker = new Worker(workerUrl || globalWorkerUrl);
94+
this._worker.addEventListener('message', this._handleWorkerMessage, false);
95+
}
96+
97+
// allow setting the workerUrl before the first Sass instance is initialized,
98+
// where registering the global workerUrl would've happened automatically
99+
Sass.setWorkerUrl = function(workerUrl) {
100+
globalWorkerUrl = workerUrl;
101+
};
102+
103+
Sass.style = {
104+
nested: 0,
105+
expanded: 1,
106+
compact: 2,
107+
compressed: 3
108+
};
109+
110+
Sass.comments = {
111+
'none': 0,
112+
'default': 1
113+
};
114+
115+
Sass.prototype = {
116+
style: Sass.style,
117+
comments: Sass.comments,
118+
119+
destroy: function() {
120+
this._worker && this._worker.terminate();
121+
this._worker = null;
122+
this._callbacks = {};
123+
this._importer = null;
124+
},
125+
126+
_handleWorkerMessage: function(event) {
127+
if (event.data.command) {
128+
this[event.data.command](event.data.args);
129+
}
130+
131+
this._callbacks[event.data.id] && this._callbacks[event.data.id](event.data.result);
132+
delete this._callbacks[event.data.id];
133+
},
134+
135+
_dispatch: function(options, callback) {
136+
if (!this._worker) {
137+
throw new Error('Sass worker has been terminated');
138+
}
71139

72-
Sass.prototype = {
73-
style: Sass.style,
74-
comments: Sass.comments,
75-
76-
destroy: function() {
77-
this._worker && this._worker.terminate();
78-
this._worker = null;
79-
this._callbacks = {};
80-
this._importer = null;
81-
},
82-
83-
_handleWorkerMessage: function(event) {
84-
if (event.data.command) {
85-
this[event.data.command](event.data.args);
86-
}
87-
88-
this._callbacks[event.data.id] && this._callbacks[event.data.id](event.data.result);
89-
delete this._callbacks[event.data.id];
90-
},
91-
92-
_dispatch: function(options, callback) {
93-
if (!this._worker) {
94-
throw new Error('Sass worker has been terminated');
95-
}
96-
97-
options.id = 'cb' + Date.now() + Math.random();
98-
this._callbacks[options.id] = callback;
99-
this._worker.postMessage(options);
100-
},
101-
102-
_importerInit: function(args) {
103-
// importer API done callback pushing results
104-
// back to the worker
105-
var done = function done(result) {
106-
this._worker.postMessage({
107-
command: '_importerFinish',
108-
args: [result]
109-
});
110-
}.bind(this);
111-
112-
try {
113-
this._importer(args[0], done);
114-
} catch(e) {
115-
done({ error: e.message });
116-
throw e;
117-
}
118-
},
119-
120-
importer: function(importerCallback, callback) {
121-
if (typeof importerCallback !== 'function' && importerCallback !== null) {
122-
throw new Error('importer callback must either be a function or null');
123-
}
124-
125-
// callback is executed in the main EventLoop
126-
this._importer = importerCallback;
127-
// tell worker to activate importer callback
140+
options.id = 'cb' + Date.now() + Math.random();
141+
this._callbacks[options.id] = callback;
142+
this._worker.postMessage(options);
143+
},
144+
145+
_importerInit: function(args) {
146+
// importer API done callback pushing results
147+
// back to the worker
148+
var done = function done(result) {
128149
this._worker.postMessage({
129-
command: 'importer',
130-
args: [Boolean(importerCallback)]
150+
command: '_importerFinish',
151+
args: [result]
131152
});
153+
}.bind(this);
132154

133-
callback && callback();
134-
},
135-
};
155+
try {
156+
this._importer(args[0], done);
157+
} catch(e) {
158+
done({ error: e.message });
159+
throw e;
160+
}
161+
},
136162

137-
var commands = 'writeFile readFile listFiles removeFile clearFiles lazyFiles preloadFiles options compile compileFile';
138-
commands.split(' ').forEach(function(command) {
139-
Sass.prototype[command] = function() {
140-
var callback = slice.call(arguments, -1)[0];
141-
var args = slice.call(arguments, 0, -1);
142-
if (typeof callback !== 'function') {
143-
args.push(callback);
144-
callback = noop;
145-
}
146-
147-
this._dispatch({
148-
command: command,
149-
args: args
150-
}, callback);
151-
};
152-
});
153-
154-
// automatically set the workerUrl in case we're loaded by a simple
155-
// <script src="path/to/sass.js"></script>
156-
// see https://github.com/medialize/sass.js/pull/32#issuecomment-103142214
157-
// we can only run this test in the browser,
158-
// so make sure we actually have a DOM to work with
159-
if (typeof document !== 'undefined' && document.getElementsByTagName) {
160-
// http://www.2ality.com/2014/05/current-script.html
161-
var currentScript = document.currentScript || (function() {
162-
var scripts = document.getElementsByTagName('script');
163-
return scripts[scripts.length - 1];
164-
})();
165-
166-
var defaultWorkerUrl = currentScript && currentScript.src;
167-
// make sure we're not running in some concatenated thing
168-
if (defaultWorkerUrl && defaultWorkerUrl.slice(-8) === '/sass.js') {
169-
Sass.setWorkerUrl(defaultWorkerUrl.slice(0, -8) + '/sass.worker.js');
163+
importer: function(importerCallback, callback) {
164+
if (typeof importerCallback !== 'function' && importerCallback !== null) {
165+
throw new Error('importer callback must either be a function or null');
170166
}
171-
}
172167

173-
return Sass;
168+
// callback is executed in the main EventLoop
169+
this._importer = importerCallback;
170+
// tell worker to activate importer callback
171+
this._worker.postMessage({
172+
command: 'importer',
173+
args: [Boolean(importerCallback)]
174+
});
175+
176+
callback && callback();
177+
},
178+
};
179+
180+
var commands = 'writeFile readFile listFiles removeFile clearFiles lazyFiles preloadFiles options compile compileFile';
181+
commands.split(' ').forEach(function(command) {
182+
Sass.prototype[command] = function() {
183+
var callback = slice.call(arguments, -1)[0];
184+
var args = slice.call(arguments, 0, -1);
185+
if (typeof callback !== 'function') {
186+
args.push(callback);
187+
callback = noop;
188+
}
189+
190+
this._dispatch({
191+
command: command,
192+
args: args
193+
}, callback);
194+
};
195+
});
196+
197+
// automatically set the workerUrl in case we're loaded by a simple
198+
// <script src="path/to/sass.js"></script>
199+
// see https://github.com/medialize/sass.js/pull/32#issuecomment-103142214
200+
Sass.setWorkerUrl(SASSJS_RELATIVE_PATH + '/sass.worker.js');
201+
return Sass;
174202
}));

dist/sass.sync.js

Lines changed: 77 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/sass.worker.js

Lines changed: 24 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/versions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"commit": "a6482aa"
99
},
1010
"sassjs": {
11-
"version": "0.9.0",
12-
"commit": "59917af",
11+
"version": "0.9.1",
12+
"commit": "55d8d3f",
1313
"branch": "master"
1414
}
1515
}

0 commit comments

Comments
 (0)