requirejs timeout error - timeout

I'm using js/html/node-webkit to build standalone app and have an issue with loading js files.
Files tree:
/
|-files/
| |-additionals/
| | |-jquery.form.js
| |-bootstrap/
| | |-js/
| | | |-boostrap.min.js
| |-CatalogSmall.js
| |-jquery.js
| |-main.js
| |-parse2.js
|-index.html
|-index.js
|-require.js
My index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" data-main="index.js" src="require.js"></script>
</head>
<body>
</body>
</html>
My index.js
var appDir = "/home/user/p1";
requirejs.config(
{
baseUrl: appDir,
paths:
{
files: "files_",
bootstrap: "files_/bootstrap/js",
additionals: "files_/additionals",
jui: "jui"
}
});
requirejs(
[ "files_/jquery" ],
function ()
{
requirejs(
[
"jui/jquery-ui-1.9.1.custom.min",
"additionals/jquery.form",
"bootstrap/bootstrap.min",
],
function ()
{
//some code
requirejs.config({ waitSeconds: 180 });
requirejs(
["files/CatalogSmall"],
function ()
{
requirejs(
["files/parse2"],
function ()
{
//some code
}
);
}
);
CatalogSmall is a huge file in json-style
So, if I load my sripts directly from index.html there is no errors, but if I try to load them via requirejs, I have an error "Uncaught Error: Load timeout for modules: files/CatalogSmall" after 180 secs. Have no idea how to fix it.

var appDir = "/home/user/p1";
You don't have local access to files anyway, what is the point of this line?
The appDir option is for the case that all your code in within a subfolder below your index.js. In this case you don't need it.
files: "files_",
This makes no sense as well. The paths object contains only module paths, not folder paths.
The options are documented here.

Related

Couldn't compile yew

I am using build a sample app from yew docs. I don't know why this app throw this error.
this is yew version in Cargo.toml
[dependencies]
yew = { version = "0.20.0", features = ["csr"] }
this is code in main.rs
use yew::prelude::*;
#[function_component]
fn App() -> Html {
let counter = use_state(|| 0);
let onclick = {
let counter = counter.clone();
move |_| {
let value = *counter + 1;
counter.set(value);
}
};
html! {
<div>
<button {onclick}>{ "+1" }</button>
<p>{ *counter }</p>
</div>
}
}
fn main() {
yew::Renderer::<App>::new().render();
}
this is index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Yew App</title>
</head>
The code in your screenshot doesn't quite match the example you posted here (there's no UseStateHandle, etc) but assuming that's not an issue I took a quick look at
~/.cargo/registry/src/github.com-1ecc6299db9ec823/yew-0.20.0/src/lib.rs on my system and
https://github.com/yewstack/yew/blob/master/packages/yew/src/lib.rs on github
Neither of those has a pub(crate) fn start_app() -> { at line 348. They only have 346 lines.
I suspect something's wrong with your cargo registry.
You should take a closer look at the files on your system to confirm this.
I don't know if there's a way to correct this but if I were to encounter this condition I would
rename my ~/.cargo/registry to something like ~/.cargo/registry.bak
and then try again.
If that fixed the problem I'd remove the ~/.cargo/registry.bak. If not I'd put it back.

Rails 7 Import Map. Uncaught SyntaxError: The requested module 'vega-loader' does not provide an export named 'default'

I'm using Rails 7 import map feature to build a chart.
This is what I did.
./bin/importmap pin vega#5
./bin/importmap pin vega-lite#5
./bin/importmap pin vega-embed#6
And in the browser, I can see this Uncaught SyntaxError: The requested module 'vega-loader' does not provide an export named 'default' error on the console.
This is the similar code from the https://generator.jspm.io/ sandbox.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!--
JSPM Generator Import Map
Edit URL: https://generator.jspm.io/#U2VhYGBmD80rySzJSU1hKEtNT9RNzU1KTXEw0zMy1DOAiORklqQ6mOqZQflAppGRniEAk3dJ3DwA
-->
<script type="importmap">
{
"imports": {
"vega": "https://ga.jspm.io/npm:vega#5.22.1/build/vega.module.js",
"vega-embed": "https://ga.jspm.io/npm:vega-embed#6.21.0/build/vega-embed.module.js",
"vega-lite": "https://ga.jspm.io/npm:vega-lite#5.6.0/build/src/index.js"
},
"scopes": {
"https://ga.jspm.io/": {
"buffer": "https://ga.jspm.io/npm:#jspm/core#2.0.0-beta.27/nodelibs/browser/buffer.js",
"clone": "https://ga.jspm.io/npm:clone#2.1.2/clone.js",
"d3-array": "https://ga.jspm.io/npm:d3-array#3.1.1/src/index.js",
"d3-color": "https://ga.jspm.io/npm:d3-color#3.1.0/src/index.js",
"d3-delaunay": "https://ga.jspm.io/npm:d3-delaunay#6.0.2/src/index.js",
"d3-dispatch": "https://ga.jspm.io/npm:d3-dispatch#3.0.1/src/index.js",
"d3-dsv": "https://ga.jspm.io/npm:d3-dsv#3.0.1/src/index.js",
"d3-force": "https://ga.jspm.io/npm:d3-force#3.0.0/src/index.js",
"d3-format": "https://ga.jspm.io/npm:d3-format#3.1.0/src/index.js",
"d3-geo": "https://ga.jspm.io/npm:d3-geo#3.0.1/src/index.js",
"d3-geo-projection": "https://ga.jspm.io/npm:d3-geo-projection#4.0.0/src/index.js",
"d3-hierarchy": "https://ga.jspm.io/npm:d3-hierarchy#3.1.2/src/index.js",
"d3-interpolate": "https://ga.jspm.io/npm:d3-interpolate#3.0.1/src/index.js",
"d3-path": "https://ga.jspm.io/npm:d3-path#3.0.1/src/index.js",
"d3-quadtree": "https://ga.jspm.io/npm:d3-quadtree#3.0.1/src/index.js",
"d3-scale": "https://ga.jspm.io/npm:d3-scale#4.0.2/src/index.js",
"d3-shape": "https://ga.jspm.io/npm:d3-shape#3.1.0/src/index.js",
"d3-time": "https://ga.jspm.io/npm:d3-time#3.0.0/src/index.js",
"d3-time-format": "https://ga.jspm.io/npm:d3-time-format#4.1.0/src/index.js",
"d3-timer": "https://ga.jspm.io/npm:d3-timer#3.0.1/src/index.js",
"delaunator": "https://ga.jspm.io/npm:delaunator#5.0.0/index.js",
"fast-deep-equal": "https://ga.jspm.io/npm:fast-deep-equal#3.1.3/index.js",
"fast-json-patch": "https://ga.jspm.io/npm:fast-json-patch#3.1.1/index.mjs",
"fast-json-stable-stringify": "https://ga.jspm.io/npm:fast-json-stable-stringify#2.1.0/index.js",
"internmap": "https://ga.jspm.io/npm:internmap#2.0.3/src/index.js",
"json-stringify-pretty-compact": "https://ga.jspm.io/npm:json-stringify-pretty-compact#3.0.0/index.js",
"robust-predicates": "https://ga.jspm.io/npm:robust-predicates#3.0.1/index.js",
"topojson-client": "https://ga.jspm.io/npm:topojson-client#3.1.0/dist/topojson-client.js",
"vega-canvas": "https://ga.jspm.io/npm:vega-canvas#1.2.6/build/vega-canvas.min.js",
"vega-crossfilter": "https://ga.jspm.io/npm:vega-crossfilter#4.1.0/build/vega-crossfilter.module.js",
"vega-dataflow": "https://ga.jspm.io/npm:vega-dataflow#5.7.4/build/vega-dataflow.js",
"vega-encode": "https://ga.jspm.io/npm:vega-encode#4.9.0/build/vega-encode.module.js",
"vega-event-selector": "https://ga.jspm.io/npm:vega-event-selector#3.0.0/build/vega-event-selector.module.js",
"vega-expression": "https://ga.jspm.io/npm:vega-expression#5.0.0/build/vega-expression.module.js",
"vega-force": "https://ga.jspm.io/npm:vega-force#4.1.0/build/vega-force.module.js",
"vega-format": "https://ga.jspm.io/npm:vega-format#1.1.0/build/vega-format.module.js",
"vega-functions": "https://ga.jspm.io/npm:vega-functions#5.13.0/build/vega-functions.module.js",
"vega-geo": "https://ga.jspm.io/npm:vega-geo#4.4.0/build/vega-geo.module.js",
"vega-hierarchy": "https://ga.jspm.io/npm:vega-hierarchy#4.1.0/build/vega-hierarchy.module.js",
"vega-interpreter": "https://ga.jspm.io/npm:vega-interpreter#1.0.4/build/vega-interpreter.js",
"vega-label": "https://ga.jspm.io/npm:vega-label#1.2.0/build/vega-label.module.js",
"vega-loader": "https://ga.jspm.io/npm:vega-loader#4.5.0/build/vega-loader.browser.module.js",
"vega-parser": "https://ga.jspm.io/npm:vega-parser#6.1.4/build/vega-parser.module.js",
"vega-projection": "https://ga.jspm.io/npm:vega-projection#1.5.0/build/vega-projection.module.js",
"vega-regression": "https://ga.jspm.io/npm:vega-regression#1.1.0/build/vega-regression.module.js",
"vega-runtime": "https://ga.jspm.io/npm:vega-runtime#6.1.3/build/vega-runtime.js",
"vega-scale": "https://ga.jspm.io/npm:vega-scale#7.2.0/build/vega-scale.module.js",
"vega-scenegraph": "https://ga.jspm.io/npm:vega-scenegraph#4.10.1/build/vega-scenegraph.module.js",
"vega-schema-url-parser": "https://ga.jspm.io/npm:vega-schema-url-parser#2.2.0/dist/parser.js",
"vega-selections": "https://ga.jspm.io/npm:vega-selections#5.4.0/build/vega-selection.module.js",
"vega-statistics": "https://ga.jspm.io/npm:vega-statistics#1.8.0/build/vega-statistics.module.js",
"vega-themes": "https://ga.jspm.io/npm:vega-themes#2.12.0/build/vega-themes.module.js",
"vega-time": "https://ga.jspm.io/npm:vega-time#2.1.0/build/vega-time.module.js",
"vega-tooltip": "https://ga.jspm.io/npm:vega-tooltip#0.28.0/build/vega-tooltip.module.js",
"vega-transforms": "https://ga.jspm.io/npm:vega-transforms#4.10.0/build/vega-transforms.module.js",
"vega-util": "https://ga.jspm.io/npm:vega-util#1.17.0/build/vega-util.module.js",
"vega-view": "https://ga.jspm.io/npm:vega-view#5.11.0/build/vega-view.module.js",
"vega-view-transforms": "https://ga.jspm.io/npm:vega-view-transforms#4.5.8/build/vega-view-transforms.js",
"vega-voronoi": "https://ga.jspm.io/npm:vega-voronoi#4.2.0/build/vega-voronoi.module.js",
"vega-wordcloud": "https://ga.jspm.io/npm:vega-wordcloud#4.1.3/build/vega-wordcloud.js"
}
}
}
</script>
<!-- ES Module Shims: Import maps polyfill for modules browsers without import maps support (all except Chrome 89+) -->
<script async src="https://ga.jspm.io/npm:es-module-shims#1.5.1/dist/es-module-shims.js" crossorigin="anonymous"></script>
<script type="module">
import * as vega from "vega";
import * as vegaEmbed from "vega-embed";
import * as vegaLite from "vega-lite";
// Write main module code here, or as a separate file with a "src" attribute on the module script.
console.log(vega, vegaEmbed, vegaLite);
</script>
</body>
</html>

Adding filetransfer in PhoneGap breaks build

I'm trying to upload a video to a server in PhoneGap. The code is running in terms of opening the camera dialog and recording the video, but then the JS in the index.html file requires use of the FileTransfer plugin.
Adding this plugin from the phonegap command line results in the following error...
/platforms/ios/ManUtd/Plugins/org.apache.cordova.file-transfer/CDVFileTransfer.m:23:9: 'CDVLocalFilesystem.h' file not found
The html file is the documented code from the PhoneGap website
<!DOCTYPE html>
<html>
<head>
<title>Capture Video</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Called when capture operation is finished
//
function captureSuccess(mediaFiles) {
var i, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
uploadFile(mediaFiles[i]);
}
}
// Called if something bad happens.
//
function captureError(error) {
var msg = 'An error occurred during capture: ' + error.code;
navigator.notification.alert(msg, null, 'Uh oh!');
}
// A button will call this function
//
function captureVideo() {
// Launch device video recording application,
// allowing user to capture up to 2 video clips
navigator.device.capture.captureVideo(captureSuccess, captureError, {limit: 2});
}
// Upload files to server
function uploadFile(mediaFile) {
var ft = new FileTransfer(),
path = mediaFile.fullPath,
name = mediaFile.name;
ft.upload(path,
"http://my.domain.com/upload.php",
function(result) {
console.log('Upload success: ' + result.responseCode);
console.log(result.bytesSent + ' bytes sent');
},
function(error) {
console.log('Error uploading file ' + path + ': ' + error.code);
},
{ fileName: name });
}
</script>
</head>
<body>
<button onclick="captureVideo();">Capture Video</button> <br>
</body>
</html>
I have run both these commands and both result in the code breaking
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer.git
I am targeting iOS only at the moment
This appears to be related to the whole PhoneGap/Cordova thing.
Creating a new project using Cordova instead of PhoneGap, has sorted the problem. It appears as if the FileTransfer API is broken if you start an app using PhoneGap.

tinymce editor using opa

import stdlib.core.web.resource
Editor = {{
base_url = Resource.base_url?""
load = <script type="text/javascript" src="{base_url}/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
#client init()=
((%% editor.init %%)())
#client getContent(dom : string)=
((%% editor.getContent %%)(dom))
tiny_mce = #static_resource_directory("tinymce")
}}
while running this above code I'm getting below error
Error
File "editor.opa", line 20, characters 6-25, (20:6-20:25 | 339-358)
Unable to type bypass
editor_init.
can anyone help me please?
I think you had not created the bypass before.
First use :
opa-plugin-builder editor.js
With a file "editor.js" like that :
##register init: -> void
##args()
{
tinyMCE.init({
mode: "textareas",
theme: "advanced"
});
}
##register getContent: string -> string
##args(a)
{
return tinyMCE.get(a).getContent();
}
And then you must get a folder named editor.opp
And now to compile editor.opa, you must call editor.opp
ex :
opa editor.opp editor.opa
Hope it helps :)

Trouble using Titanium's webview to fire an API event

I'm trying to fire an event from an external HTML page opened inside of Titanium's webview.
app.js file...
var group, now, tab, view, window;
now = new Date();
view = Titanium.UI.createWebView({url: 'http://MYWEBSITE.com/index.htm?time=' + now.getTime()});
window = Titanium.UI.createWindow({tabBarHidden: true, navBarHidden: true});
window.add(view);
Titanium.App.addEventListener('browse', function(e) {
Ti.API.info("I received " + e.something + " from the webview.");
});
group = Titanium.UI.createTabGroup();
tab = Titanium.UI.createTab({title: 'window', window: window});
group.addTab(tab);
group.open(tab);
js excerpt from web page...
$("#testButton").mousedown(function() {
alert ("I got clicked.");
Ti.App.fireEvent('browse', {something:'stuff'});
});
(I include the time in the URL to ensure the page is always fresh.)
Adding the event listener as shown above, or using view.addEventListener, compiles but ultimately doesn't work.
Using Titanium.UI.WebView.addEventListener produces an error message that the object doesn't exist.
Do I need to open the URL/webview in a different manner?
Also, since Titanium.App.fireEvent is not a recognized function, except to Titanium, how does one prevent a JavaScript error?
Thanks.
// from web page
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div id='testButton'>TEST BUTTON</div>
</body>
<script>
var _button = document.getElementById ("testButton");
_button.onmousedown = function () {
alert (this.id);
Ti.App.fireEvent('fromwebview', {name:this.id});
return false;
};
</script>
</html>
from apps.js
Ti.App.addEventListener('fromwebview', function(data)
{
Titanium.API.info("--> " + data.name);
});
Just to warn you all - I don't think this works with remote pages anymore for security reasons. Spent ages trying fruitlessly!
You can make this work on your remote html page by including the Titanium Injection code. For sdk 1.8.3 it's the following. Now your remote html page can talk to the device.
var Ti = {_event_listeners:[],createEventListener:function(listener ){ var newListener={ listener:listener ,systemId:-1 ,index:this._event_listeners.length };this._event_listeners.push(newListener);return newListener;},getEventListenerByKey:function(key,arg){for(var i=0;i<this._event_listeners.length;i++){if(this._event_listeners[i][key]==arg){return this._event_listeners[i];}} return null;},API:TiAPI,App:{addEventListener:function(eventName,listener) {var newListener=Ti.createEventListener(listener);newListener.systemId=TiApp.addEventListener(eventName,newListener.index);return newListener.systemId;},removeEventListener:function(eventName,listener) {if(typeof listener=='number'){TiApp.removeEventListener(eventName,listener);var l=Ti.getEventListenerByKey('systemId',listener);if(l!==null){Ti._event_listeners.splice(l.index,1);}}else{l=Ti.getEventListenerByKey('listener',listener);if(l!==null){TiApp.removeEventListener(eventName,l.systemId);Ti._event_listeners.splice(l.index,1);}}},fireEvent:function(eventName,data) {TiApp.fireEvent(eventName,JSON.stringify(data));}},executeListener:function(id,data) {var listener=this.getEventListenerByKey('index',id);if(listener!==null){listener.listener.call(listener.listener,data);}}};var Titanium=Ti;

Resources