stealjs / steal Goto Github PK
View Code? Open in Web Editor NEWGets JavaScript
Home Page: https://stealjs.com
License: MIT License
Gets JavaScript
Home Page: https://stealjs.com
License: MIT License
Running "./steal/js steal/make.js" will successfully copy the js script, but I have to chmod the file to make it executable before it can be run. Could this not be done in make.js?
Running ./js steal/buildjs package/package.html returns an exit code of 0 even if an error is encountered. It is suggested that an error code of 1 should be returned if a build fails.
Opening steal/test/qunit.html (or a project) in IE9 results in an error message saying "not enough stack space" (translated).
This seems to be caused by an endless loop in steal as a profiling run shows something "loopy" between 'require_continue_check' and 'require'.
I'm running JavascriptMVC 3.1 without updating. I had issues with multi-build in my app, where in production mode only, my page's main controller was not be initialised (i.e. the callback in the "then()" clause), even though its dependencies were being loaded. Works in dev mode. I've described the details in a post on the forums: http://forum.javascriptmvc.com/#Topic/32525000000609003
In steal/build/apps/apps.js:181 there is a line:
var source = "steal('//" + paths.join("'\n,'//") + "');\nsteal.end();\n" + src.join(";steal.end();\n"),
which joins scripts into a single package file.
This doesn't work if one of the scripts has a single-line comment at the end of the file - the packaged script ends up looking like:
steal.plugins('jquery/controller').then(function($){
}); // end closure; steal.end();
The fix is to add a newline in there, so the apps.js:181 line becomes:
var source = "steal('//" + paths.join("'\n,'//") + "');\nsteal.end();\n" + src.join("\n;steal.end();\n"),
Hi,
I am developing a custom steal type which builds Model classes from a downloaded schema. Here is a simplified version of my code:
steal.type("api js", function(options, success, error){
var resources = $.parseJSON(options.text);
$.each(resources, generate_model);
options.text = "";
success();
});
steal("jquery/model", "jquery/model/list")
.then({
src: "//../home?@action=api&dummy=home",
type: "api",
packaged: false
}, function($) {
"use strict";
// da da da
});
I have had two problems:
steal.type(type, cb( options, original, success, error )) -> undefined
But apparently the original parameter isn't used -- on the master branch today, this is at steal.js:1281.
The result of this is that my custom type was calling error() instead of success().
I don't think this is always desired. Perhaps there could be an option in the object passed to steal().
My resource which contains the API is called http://localhost:8917/demo/home?@action=api . It has to be called that unfortunately. The way I work around the .js addition is by adding a dummy urlparam.
Cheers,
Rodney
Calling the compressor system (e.g. Google Closure) once per input script can make build.js run much more slowly than necessary in cases where a project contains several input scripts.
if you are stealing a css file with something like this
background-image: url(image/) /{comment}/;
sample file: http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css
then build the app
the image url's end up like this ../http://ajax.googleapis.........
I think its do to the comment in the rule
Cache busting doesn't work for this file.
See:
http://forum.javascriptmvc.com/#Topic/32525000000756005
Steal within a steal does not work in IE production mode.
Example:
steal('foo.js', 'cat.js').then(function(){
steal('monkey.js').then(function(){
alert('no work');
});
});
In IE, it tries to pull the scripts from the server rather than use the production.js file. It fails shortly there after since the reference wasn't able to be pulled.
We have already a running app build with the framework. When we updated to the latest this morning we somehow isnt able to build the app anymore.
Here's whats displaying in the console:
Building to wr/
could not load script file:///c:/wamp/www/worldracers/steal/less/less_engine.js
TypeError: Cannot read property "tree" from undefined
!!!!!!!!!!! ERROR !!!!!!!!!!!
-message = Cannot read property "tree" from undefined
-fileName =
-name = TypeError
-lineNumber = 0
To verify if the issue is from our application, we tried up the javascriptmvc cookbook tutorial from scratch, from seperate directory.
Still the issue occurs when we tried to steal a less style sheet in cookbook.js. (we created cookbook.less). It displays the same result.
This is not happening from the production build that can be downloaded in jmvc's website.
Hi, when will steal.js prevent cluttering of the global namespace?
I am using EJS templates in an app, but when I run pluginifyjs on it, the resulting JS file has the EJS code concatenated directly into it. Trying to load this file in a browser throws an error: "Illegal XML character '<%'". The pluginifyjs script should parse EJS code into regular JS before inserting into the final JS output, so that it is possible to embed EJS files in applications.
I have a less script containing some data-urls for small icons. After I build my app with the provided build script from jMVC, the generated code in production.css prefixes my data-urls with a reference to the jMVC application root, thus messing up the images they are supposed to represent. For example:
background-image: url(data:image/png;base64,...);
after building, is represented in the generated production.css as (my app resides in a folder called tova)
background-image: url("../../tova/data:image/png;base64,...");
However, the less script still works fine while running the app in development mode.
From : donejs/donejs#4
Running the command:
./js jquery/generate/app /home/dave/Projects/mvcapp
Generates the new app in:
/home/dave/projects/mvcapp
On case-sensitive OS's this is incorrect.
OS: Ubuntu 10.04
Release: 3.01
Before the change in following commit:
df767ea#less/less.js
I could use @import in a less file, like this:
@import "bos_vars";
And it was woking in both build and load (prod & dev env).
In the following code, if I remove test "if (!steal.isRhino) {", it works again.
var paths = [];
if (!steal.isRhino) {
var pathParts = options.src.split('/');
pathParts[pathParts.length - 1] = ''; // Remove filename
paths = [pathParts.join('/')];
}
With test (steal.isRhino), during build I get following error:
Building to cust/
failed to open file file:/c:/wwg/test/cust/scripts/bos_vars.less JavaException: java.io.FileNotFoundException:
c:\wwg\test\cust\scripts\bos_vars.less (Le fichier spécifié est introuvable = unable to find file)
!!!!!!!!!!! ERROR !!!!!!!!!!!
-message = Cannot call method "indexOf" of null
-fileName = steal/rhino/env.js
-lineNumber = 24532
-name = TypeError
Actually, build script try to load bos_vars.less from the build file path located in c:/wwg/test/cust/scripts and not from the "importer" less file path located in c:/wwg/test/bos
test
/cust
/build
/build.js
/build.html
/bos
/bos_vars.less
/bos_icon.less <-- file importing bos_vars.less
bos_icon.less file:
...
@import "bos_vars";
...
If you include the steal/less plugin, the unit tests run on Rhino (the command line) without problems BUT the script "hangs" at the end (that means the prompt does not appear anymore, at least on Ubuntu Linux). Seems like something in less prevents Rhino from exiting.
This is my quick fix:
if (!navigator.userAgent.match(/Rhino/)) {
... Plugin Code ...
} else {
steal.less = function () {};
}
Does somebody have an idea what causes this behavior? Is my fix acceptable or does it cause any problems? Of course you can not test less on the command line like this... not sure if this ever worked or if the test was supposed to run in the browser env only anyways?
Filenames containing any \wsteal.js cause DocumentJS (probably Steal in general) to load files twice. When generating the JavaScriptMVC documentation this problem occurs in steal/get/dummysteal.js and causes certain Documentation blocks to be rendered twice. Renaming it to dummy.js fixes the problem.
https://github.com/jupiterjs/steal/blob/master/html/crawl/crawl.js#L76
That line should be checking if there's a slash in hash and creating the folder with:
s.File(folderPath).mkDirs();
before creating the file.
before build:
background: url(../res/bg/bggradient.png) repeat-x;
after build
background:url(../../../file:///c:/wamp/www/worldracers/wr/game/../res/bg/bggradient.png) repeat-x;
I have a page located at '/bob/pages'. The steal directory is located at '/bob'. My javascript file is located at '/bob/pages/js/bob/headerfooter.js'.
Given the following invocation:
steal('/bob/pages/js/bob/headerfooter.js')
my javascript files load correctly. Yay!
However, if I change the invocation to use a relative path, according the leading './' syntax described here (http://javascriptmvc.com/docs.html#!steal):
steal('./js/bob/headerfooter.js')
I get a javascript error, as steal produces an invalid URL.
According to firebug, it is requesting the following:
http:/../http://localhost:8080/bob/pages/js/bob/headerfooter.js
See the "http:/.." at the start? The text after this in the URL is correct, and does point to the file it ought to, but the leading "http:/.." is causing the request to fail.
For now, having the complete path is a workaround, but it is a bit inconvenient.
steal builder crashes when coming to a hex-number.
See forum for more information.
In the past I've had mixed results trying to overwrite less_engine.js with a more up to date LESS (Rhino) release so I thought I should open an issue. The new @media stuff is nice and Twitter Bootstrap 2.0.2+ requires it to build.
I ran into a very strange occurrence today with steal which took a long time to figure out.
The situation is, I had an http main page. Inside of the page, I programatically created an iframe which included an https page. The https page used steal to include it's javascript. IE8/9 both threw an error (SEC 7111) when attaching the iframe to the outer page's DOM, which is a "mixed mode" security error.
When including steal and the files that steal includes, I do not specify the protocol. Looking at IE's network analyzer, the iframe contents and all JS files are requested using HTTPS (as expected). IE throws SEC7111 error,
As soon as I remove steal.js and instead replace it with the files that steal.js is including, everything works fine, there is no security error, everybody is happy again.
When building a production version of my app using the build scripts generated by generate/app, and after I get an (already pretty cryptic) error message:
timer error
function () {
_this.onreadystatechange();
}
TypeError: org.mozilla.javascript.Undefined@64811e10 is not a function, it is undefined.
I end up in an infinite loop which continuously generates error messages like this:
timer error
function () {
for (var timers = jQuery.timers, i = 0; i < timers.length; ++i) {
if (!timers[i]()) {
timers.splice(i--, 1);
}
}
if (!timers.length) {
jQuery.fx.stop();
}
}
TypeError: Cannot find function removeAttribute in object [object CSS2Properties].
timer error
function () {
for (var timers = jQuery.timers, i = 0; i < timers.length; ++i) {
if (!timers[i]()) {
timers.splice(i--, 1);
}
}
if (!timers.length) {
jQuery.fx.stop();
}
}
TypeError: Cannot find function removeAttribute in object [object CSS2Properties].
...
and no build ever takes place. Same happens while running the generated docs.js script. I ran steal/update and jquery/update and this keeps on happening on the latest build.
I've tried out the latest fixes in steal with multibuild support and the production version seems to depend on the order in wich 0.js, ... package files are loaded.
even so I've properly defined dependencies for the givven file, and it works ok in development build it happens that givven js file inside production.js gets "undefined" exceptions since the dependency is not available yet.
I get such exceptions almost always when browser cache is empty,i.e. when it really needs to downlaod things.
Although as mentioned in Issue 35 multibuild currently does not support CSS. So i tried in apps.js just to ignore css the similar way as you do with "fn", so they do not get included in the production.js file
.......
for ( var d = 0; d < steel.dependencies.length; d++ ) {
var dependency = steel.dependencies[d];
if ( dependency.dependencies && dependency.options.buildType != 'fn' && dependency.options.buildType != 'css' && ! dependency.options.ignore && (typeof dependency.options.packaged === 'undefined'||dependency.options.packaged == false)) { //this dependency was actually loaded
data.dependencies[dependency.options.rootSrc] = addDependencies(dependency, files, app);
}
}
}
......
it seems to work ok , but now I'm not sure if by this change i may have introduced the problem described above.
When you use LESS files in the latest master branch, set the env to 'production' in stealconfig.js , and then run the build you get:
!!!!!!!!!!! ERROR !!!!!!!!!!!
-message = Cannot read property "convert" from undefined
-fileName = file:////Users/amcdaniel2/Dev/mindjet/amcdaniel_Austin-McDaniels-MacBook-Pro/MMWebHTML/trunk/steal/steal.js?mj/ui/viewer
-lineNumber = 1511
-name = TypeError
error loading html element [object HTMLScriptElement] TypeError: Cannot read property "convert" from undefined
Updating to latest master for steal (and the other components in JavascriptMVC) and things are working correctly in dev mode, but trying to use multi-build to generate production files results in an error.
uncaught JavaScript runtime exception: TypeError: Cannot find function apps in object
Either run the build/apps test: ./js steal/build/apps/test.js
Or:
./js jquery/generate/app pages/app1
./js jquery/generate/app pages/app2
./js steal/buildjs pages/app1 pages/app2
It fails at buildjs:14 which reads steal.build.apps(urls);
, which hasn't been defined.
I've tried, admittedly vainly, to update this to use steal.build.builders.app() but, this leads to an error at steal/build/apps/apps.js:150 - the return value of steal.build.open() doesn't have a "steal" property. I think that some files are not up-to-date with the changes to steal, but it's unfortunately not clear to me what needs to be updated.
I'd be happy to get more involved to fix this issue if one of the core devs could point the way, as our app needs this working to solve some other issues we're having.
Fails with error:
org.mozilla.javascript.WrappedException: Wrapped java.io.FileNotFoundException: (steal/rhino/file.js#215)
For example:
http://github.com/secondstory/secondstoryjs-plugins
Will investigate.
When pluginifying a file with 2 or more slashes on the same line, parser fails on steal/parse/parse.js:
}else if(token.value === "/"){
print("YOU SHOULD NOT BE HERE")
this.comment();
}
I've just pushed the AMDify branch of steal (along with a CanJS version that semi works for it). Most important features:
Say you have a file at foo/bar/bar.js
that looks like:
steal(function(){
return {bar: "bq"}
})
You can steal it like:
steal('foo/bar', function( bar ) {
bar.bar //-> bq
})
Steal will go looking for stealconfig.js
in your root folder. This is a file that can mostly specify where files/modules are located. This is very important for can's compatibility layer which needs to map can/util
to something like can/util/jquery
. This can be specified in stealconfig like:
steal.map({
"can/util/util.js" : "can/util/jquery/jquery.js",
});
Also, it will be common to specify where jQuery is:
steal.map({
"can/util/util.js" : "can/util/jquery/jquery.js",
"jquery/jquery.js" : "can/util/jquery/jquery.1.7.1.js"
});
If define
or require
are used, they should work.
DateJS on its own stalls the build. It has to be wrapped with $(document).ready(function(){...}) for the build to work. Its probably doing something env/rhino doesn't like, but we should look into why no helpful errors are printed.
Steal is able to sweep out seal.dev.log from the code.
Is it possible to make steal sweep it out some other configured code pieces?
For example I use "slog" or "swarn" shortcut for steal.dev.log in my code.
If the steal.dev.log() should be an adequate replacement for console.log() IMHO it should provide the same signature, ie. be able to process more than one argument:
console.log(1, 2, 3) // outputs "1 2 3"
steal.dev.log(1, 2, 3) // outputs only "1"
I think this could be easily solved by replacing calls for console.log() in steal/dev/dev.js with something like the following:
Array.prototype.unshift.call(arguments, 'steal.js INFO:');
console.log.apply(null, arguments);
Could be similar for opera.postError() if that method also is capable of taking more than one argument.
Pluginify fails on every application I've tested saying:
!!!!!!!!!!! ERROR !!!!!!!!!!!
-message = "rhinoLoader" is not defined.
-fileName = eval(
rhinoLoader....):1347401223063
-lineNumber = 1
-name = ReferenceError
I'm using jmvc 3.2.1 and attempting to reduce page flickering during its initialization. So I've added production.css
to the head element and provided loaded
property in steal global var:
<link rel="stylesheet" type="text/css" href="production.css"/>
<script type="text/javascript">
var steal = {
app: "myapp",
env: "production",
loaded: ["myapp/production.css"]
};
</script>
<script type='text/javascript' src='../steal/steal.js'></script>
I'm getting an exception in IE browsers and production.css is loaded by steal for the second time.
Other browsers work fine and production.css
is requested only once in the head.
After some research I've found why IE is failing..
There is a section of a special IE treatment in steal.js
it starts with if (support.interactive) {
where the function below
function(name){ var src = steals[name].options.src, interactive = getCachedInteractiveScript(), interactiveSrc = interactive.src; interactives[src] = interactives[interactiveSrc]; interactives[interactiveSrc] = null; }
is being attached on steal.loaded function.
This particular function fails on var src = steals[name].options.src
line because steals["myapp/production.css"]
is undefined here.
Other browsers have no issue here because an original steal.loaded is called directly.
For some reason the paths are build really weirdly:
my original references of url(../images/smth.jpg) turns in production into: url(styles/../../app/styles/../images/smth.jpg).
Wouldn't it be better to keep the original paths? they should work in development and production mode equally
When you search for "stealjs" on google, you get:
It takes a minimum of four clicks (using the second search result) to get to http://javascriptmvc.com/docs.html#!stealjs
Suggested improvements:
Let me know how I can help!
(FYI: when you search for "steal.js", the second result is http://javascriptmvc.com/docs.html#!steal, but the first result is still the 2010 blog post.)
When building app a production css is generated. Jmvc adds some magic to this process, e.g. updating urls in the css etc. When using base64 encoded images in css (as shown below) there is a problem.
My css
a { background-image: url("data:image/png;base64,iV...ggg=="); }
Production css becomes
a { background-image: url("../data:image/png;base64,iV...ggg=="); }
Problem
"NetworkError: 404 Not Found ..."
the url should not be changed when handling css base64 image urls.
Improve the jslint error messages as per this forum request:
http://forum.javascriptmvc.com/#Topic/32525000000364021
I made a gist for a patch (file: https://github.com/jupiterjs/steal/blob/master/clean/clean.js) with a better user readable error messges:
https://gist.github.com/905709
This makes error messges like:
C:\Users\nfeger\workspace\jmvc>js steal\cleanjs vigo\models\usage_logger.js -jslint true
Beautifying vigo/models/usage_logger.js
vigo/models/usage_logger.js:16: Missing semicolon.
symbol: var y = 1
location: 18
var y = 1
^
vigo/models/usage_logger.js:28: Missing semicolon.
symbol: var x = 1
location: 18
var x = 1
^
2 errors
UNUSED
11 : y
11 : x
quiting because of JSLint Errors
When I try to build a file which steals the socket.io client, I get the following warnings caused by the document comments that include the word "function". These warning shouldn't appear because this text is part of a comment.
http://cdn.socket.io/stable/socket.io.js tmp419760.js:1670: WARNING - Parse error. missing opening ( * @param {function} listener ^ tmp419760.js:1692: WARNING - Parse error. missing opening ( * @param {function} listener ^ 0 error(s), 2 warning(s)
I was reading through the documentation and blogs but couldn't find anything that described how to load a locally sourced javascript file when a cdn file fails? Ideally I'd like to load a cdn by default, but if it fails, then resort to a locally saved version of the js file.
type() does not work correctly with FF4 on linux ubuntu 10.10 : string is duplicated with reversed characters.
S("#someInput").type('hello") gives : helloolleh
S("#someInput").type('world") gives : worlddlrow
Create a steal app where myapp/myapp.js
contains the following line, and build it:
steal('https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js');
The jQuery code is neither packaged into production.js, nor is it imported by the steal() call that appears in production.js
If we change the https to http, it works.
I needed clean.js to support more options from the command line. See patch.
diff --git a/steal/clean/clean.js b/steal/clean/clean.js
index 1c55909..1394dfe 100644
--- a/steal/clean/clean.js
+++ b/steal/clean/clean.js
@@ -94,11 +94,11 @@ steal.plugins('steal/build').then('//steal/clean/beautify','//steal/clean/jslint
*/
steal.clean = function(url, options){
options = steal.extend(
- {indent_size: 1,
- indent_char: '\t',
- space_statement_expression: true,
+ {space_statement_expression: true,
jquery : false},
steal.opts(options || {}, {
+ indent_size: 1,
+ indent_char: '\t',
//compress everything, regardless of what you find
all : 1,
//folder to build to, defaults to the folder the page is i
You can find more information here (see second to last post on this topic):
I am bottom loading steal and mouse.js and able to successfully generate production.js
but getting an error jQuery undefined while loading production.js
Can you please help me in fixing this.
https://github.com/daffl/jqueryui/blob/master/mouse/mouse.js
https://github.com/daffl/jqueryui/blob/master/widget/widget.js
https://github.com/daffl/jqueryui/blob/master/core/core.js
// index.html
<script type="text/javascript" src="./steal/steal.js?myapp/resources/jqueryui/mouse/mouse.js,development"> // build script load("steal/rhino/rhino.js"); steal("steal/build", "steal/build/scripts", "steal/build/styles", function() { steal.build("index.html", { to : "myapp/resources/jqueryui/mouse/" }); }); // here is the snippet of production.js steal.loading('myapp/resources/jqueryui/mouse/mouse.js', 'myapp/resources/jqueryui/core/core.js', 'myapp/resources/jqueryui/widget/widget.js', 'myapp/resources/jqueryui/lib/ui/jquery.ui.mouse.js', 'myapp/resources/jqueryui/stealjquery.js', 'myapp/resources/jqueryui/lib/ui/jquery.ui.core.js', 'jquery/jquery.js', 'myapp/resources/jqueryui/lib/ui/jquery.ui.widget.js'); steal("../core/core.js", "../widget/widget.js").then("../lib/ui/jquery.ui.mouse.js"); steal.loaded("myapp/resources/jqueryui/mouse/mouse.js"); steal("../stealjquery.js").then("../lib/ui/jquery.ui.core.js"); steal.loaded("myapp/resources/jqueryui/core/core.js"); steal("../stealjquery.js").then("../lib/ui/jquery.ui.widget.js"); steal.loaded("myapp/resources/jqueryui/widget/widget.js"); (function (h) { // ../lib/ui/jquery.ui.mouse.js code }(jQuery) // ERROR // Actual jquery code is below this lineAn early return statement in steal.end() was stopping 'first_wave_done' from ever being set to true. I have a commit which fixes this in my fork.
I have a page loaded from http://example.com/subdir1/subdir2/page.html which steals a less file (let's call it main.less) containing @import statements:
@import "more.less";
main.less loads fine, but javascriptmvc/steal/less/less_engine.js crashes on line 2403 due to a HTTP 404 error:
Couldn't load http://example.com/subdir1/subdir2//js/myproject/more.less (404)
The URL is wrong, it should be http://example.com/js/myproject/more.less . I have a fix, but I'm not sure whether it makes things go wrong in other use cases:
simon@ubuntu:~/javascriptmvc/js/steal/less$ diff less.orig.js less.js
75c75
< var newPath = location.href.replace(/[\w\.-]+$/, '')+
---
> var newPath = location.protocol+'//'+location.host+
Cheers, simon
I have experienced some out of order loading of files with the master-version of steal. I guess it could be caused by this commit, but did not verify that assumption yet: b06aaee
More info in my comment over there
Is it possible to make automatic dependencies for less (coffee) resources on less/coffee compiler?
now it is needed to do like:
steal(.."steal/less"...).then("style.less")
but why not do this without need to explicitly steal less plugin?
steal(.."style.less"...)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.