Chrome Extension Manifest Relative File Path for Scripts - google-chrome

I have several utility script files that are used by multiple extensions. Thus far, I have been copy/pasting those utility scripts to each extension's root folder whenever I make a change. This is becoming less and less feasible. I would like to reference the same utility script files from both extensions' manifests. I have tried this:
{
"background":
{
"scripts":
[
"../utils.js",
"background.js"
]
}
}
But, I when I reload my extension, I get an Extension error saying:
Could not load extension from 'C:\...'. Could not load background script '../../utils.js'.
If I use backslashes instead (this seems like a more likely solution since I'm working with windows...), I get the same error (but with backslashes).
Is it even possible to achieve this type of relative file path?

How about creating a local server that hosts the JS files you need and then your extension can access those JS file through a localhost port and use their functionality? A simple lightweight server would do the trick (maybe bottle.py in Python).
Chrome v33 tightened up extension security so i'm not sure you can access a file like you tried in your manifest.json
Let me know how you get around this problem!

Have you considered using Shared Modules? According to the documentation you can export common functionality from one extension that can thusly be imported into another extension:
"The export field indicates an extension is a Shared Module that exports its resources:
{
"version": "1.0",
"name": "My Shared Module",
"export": {
// Optional list of extension IDs explicitly allowed to
// import this Shared Module's resources. If no whitelist
// is given, all extensions are allowed to import it.
"whitelist": [
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
]
}
// Note: no permissions are allowed in Shared Modules
}
The import field is used by extensions and apps to declare that they depend on the resources from particular Shared Modules:
{
"version": "1.0",
"name": "My Importing Extension",
...
"import": [
{"id": "cccccccccccccccccccccccccccccccc"},
{"id": "dddddddddddddddddddddddddddddddd"
"minimum_version": "0.5" // optional
},
]
}
"

Related

Very odd Cordova/Phonegap JSON error: Unexpected token in JSON at position 0

So i've been developing an app for the past few weeks. I have never messed with any json file whatsoever. Today I tried to run my app and it shows a very odd error from Cordova, Error:
Error: Unexpected token in JSON at position 0
The token is ' '?
Which JSON file is it? I went over all the main Json package files, and all of them started with the 0'th token as a '{'.
I'm completely lost, I didn't do anything at all, I didn't add a plugin or something that day it just appeared out of no where.
I have no idea which json files to attach here, there are dozens of them in the project directory.. Any ideas or direction will be extremely helpful, thanks.
Check plugins/*.json
There's most likely an issue hiding in one of those files.
For me it was an unresolved merge conflict inside fetch.json
Run npm install and it will give you more details of the error. In my case, it was an extra comma in package.json. It is a painful bug and I wish cordova explicitly mentioned where this issue was!
You had to check the file fetch.json in Plugins folder. Fetch.json must be encode in UTF8 and at the end of the JSON, the file need to finish correctly, without a comma, like this :
{
"es6-promise-plugin": {
"source": {
"type": "registry",
"id": "es6-promise-plugin#^4.1.0"
},
"is_top_level": false,
"variables": {}
},
"cordova-plugin-nativestorage": {
"source": {
"type": "registry",
"id": "cordova-plugin-nativestorage#^2.3.2"
},
"is_top_level": true,
"variables": {}
} //No Comma
}
Good luck !
My approach to any JSON error:
[optional] Remove/uninstall all plugins
Delete all your platform directory folders (ie. browser, Android, iOS etc,), and delete the package.json file
Note: Don't delete the package-lock.json file
Create a new package.json file by running npm init on your command line (run this command on your Cordova project directory).
Make sure you create this file with the same package name you used before. If you don't remember, you can check the config.xml file (including the 'version').
Reinstall all your plugins (if you followed step 1).
Add your platforms.
Run, build your Cordova project.
If it fails, follow step 1 to the last step.
It works 100℅
If this doesn't work, contact me and send me your issues.

Multiple Aurelia Apps Side by Side

I'm currently tasked with building 2 UI's for a service I've constructed.
The output from both of these UI's will need to end up in the same root folder.
I found the section that names the basic bundles in the "aurelia.json" file, and renamed the bundles created for my project, when built, my project as expected created 2 new bundles in the scripts directory with the new names.
However, upon running my project, I then found that index.html was getting a 404 trying to load the "vendor-bundle" (Which I had renamed to 'service-vendor-bundle').
No problem there, I just edited index.html to reference the new file, and bingo, 404 resolved.
The problem is however, that "service-vendor-bundle" can now not load "service-app-bundle".
I assumed (Probably incorrectly) that, when I renamed the bundles in my aurelia.json file, that the build output would also be configured appropriately to load the files in.
I need to be able to customize this beacuse once the 2 aurelia apps are finished, they will need to share a scripts folder, so I'll need
uione.html to load "scripts\uione-vendor-bundle.js" and "scripts\uione-app-bundle.js"
and I'll need
uitwo.html to load "scripts\uitwo-vendor-bundle.js" and "scripts\uitwo-app-bundle.js"
The final file layout once on the server will look something like the following:
root
uione.html
uitwo.html
scripts
uione-vendor-bundle.js
uione-app-bundle.js
uitwo-vendor-bundle.js
uitwo-app-bundle.js
images
*.png
Both client apps have to be developed separate from each other and be stand alone, so I can't combine them into one app, and I cant put them into seperate folders as the service that will be serving them is a custom in house built service, specifically configured to only serve from a single folder, with a single scripts and images folder.
My aurelia.json file currently looks like this:
.........
"plugins": [
{
"name": "text",
"extensions": [
".html",
".css"
],
"stub": true
}
]
},
"options": {
"minify": "stage & prod",
"sourcemaps": "dev & stage"
},
"bundles": [
{
"name": "uione-app-bundle.js",
"source": [
"[**/*.js]",
"**/*.{css,html}"
]
},
{
"name": "uione-vendor-bundle.js",
"prepend": [
"node_modules/bluebird/js/browser/bluebird.core.js",
"node_modules/requirejs/require.js"
],
..........
and I'm using the Aurelia cli tool (au ...) for my Aurelia based tasks.
Any pointers on how to achieve this would be great.
I think you're on the right track by customizing the bundle names.
What you can do is manually load both the vendor bundle and the app bundle. That way the app modules are already downloaded and ready to use, instead of letting the vendor bundle try to download it manually.
index.html
<body aurelia-app="main">
<script src="scripts/my-special-vendor-bundle.js" data-main="aurelia-bootstrapper"></script>
<script src="scripts/my-special-app-bundle.js"></script>
</body>
I have tested this and it is working fine for me. I am using this manual loading technique in my own project to allow ASP.Net script versioning to provide cache-busting (see my answer here).

Is it possible to have a global launch.json file?

I am using Don Jayamanne's Python extension and it is working well. The only issue I have is for every project I work on, I have to copy the \.vscode\launch.json file. I was wondering if there is a way to place that file somewhere globally so the settings are applied to all my projects. Something similar to how the global settings.json works for user settings.
In other words I am looking for a way to avoid having to copy \.vscode\launch.json to every folder I store and write python code in.
Yes, it is possible - you need to put the requisite launch config directly in your user settings file, as described here.
From the linked page:
... currently it is not possible to have one global launch.json file which would be used everywhere, but what works is to add a "launch" object inside your user settings (preferences > user settings). This way it will be shared across all your workspaces
Example:
"launch": {
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${file}",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "/usr/local/bin/node"
}
]
}

Sublime Text Config Q

(Running ST2 on Win7)
Just looking into ST2 as an ide for WebDev. I've introduced a few packages, but have got a bit lost in the configuration of them! I've a couple of problems.
Firstly I've got ST2 configured to open the browser on file save, but unfortunately it opens all files rather than just .html files. Ideally I'd like it to live refresh if the js is already in use, but in the worst case, just open .html files and ignore .js files
Secondly when it opens a .html file it opens it as a file rather than via SublimeServer which is running. I've followed this link and believe SublimeServer is running on the same port.
Here's the SublimeServer config:
{
"attempts": 5,
"autorun": true,
"interval": 500,
"mimetypes":
{
"": "application/octet-stream",
".c": "text/plain",
".h": "text/plain",
".py": "text/plain"
},
"port": 8000
}
and the proj config
{
"folders":
[
{
"path": "/E/Projects/MyProjects/My.Web/My.Web.App/My.Web.App.Designer"
}
],
"settings":
{
"sublime-view-in-browser":
{
"baseUrl": "http://localhost:8000/",
"basePath": "E:\\Projects\\MyProjects\\My.Web\\My.Web.App\\My.Web.App.Designer"
}
}
}
So where do I need to look in the config to modify this behaviour?
EDIT:
The packages I currently have installed are:
Bracket Highlighter
Browser Refresh
DocBlockr
Emmet
Git
Grunt
JSLint
Nodejs
Package Control
Side Bar
SublimeCodeIntel
SublimeLinter
View in Browser
Web Inspector
(and SublimeServer)
I pretty much got them all from Package Control.
As I newbie, I may need to pair some of these back.
Many thx IA
Simon

Error :Submitting the app to Firefox Market Place

I am trying to submit a new app into the firefox marketplace but I don`t know why it is showing the below error..
Your app failed validation with 1 error.
Error extracting manifest from zip file.
I cannot install it through server to b2g mobile too as mentioned here.. as it is saying "Download Failed in the mobile.
Here`s my manifest file
{ "name": "Check Location", "description": "This app allows you to check your Location!", "launch_path": "/app.html", "developer": { "name": "RB", "url": "http://nothing.me" }, "icons": { "16": "/img/icon16.png", "32": "/img/icon32.png", "48": "/img/icon48.png", "64": "/img/icon64.png", "128": "/img/icon128.png" }, "default_locale": "en", "permissions": { "geolocation": {
"description" : "Marking out user location"
} } }
Here`s package.manifest
{ "name": "Check Location", "description": "This app allows you to check your Location!", "launch_path": "/app.html", "developer": { "name": "RB", "url": "http://nothing.me" }, "icons": { "16": "/img/icon16.png", "32": "/img/icon32.png", "48": "/img/icon48.png", "64": "/img/icon64.png", "128": "/img/icon128.png" }, "default_locale": "en", "permissions": { "geolocation": {
"description" : "Marking out user location"
} } }
I have done pasting Index.html, css and js folder into the package folder and zipped it as they have mentioned. But when I upload the zip file into the market place it is showing the error.. Please help me with this.. Check out the complete code Here
The error simply denotes that system cannot find manifest.webapp from your zip file.
https://github.com/mozilla/zamboni/blob/master/mkt/developers/forms.py#L512
You should make sure manifest.webapp is in root directory of your .zip file.
One possible mistake might be doing like below:
zip -r foo.zip foo/*
This will create a zip file whose root only contains foo folder, thus the submission system cannot find your manifest.
You should instead do:
cd foo
zip -r foo.zip *
Hope it helps!
Do not zip the main folder of the app directly.if you saved your app content in a main folder then open folder select all the contents and then select compress or Zip option.Submit it to the Marketplace.
Without seeing the zip file it is hard to say what exactly is wrong. Is this a packaged or hosted app? For hosted apps, you do not need to zip the app and can just pass the URL of you manifest to the validator. Of course, you have to first upload the app to it's unique domain.
There is a mailing list for webapp developers (dev-webapps) and one to contact app reviewers (app-reviewers). I would try dev-webapps since you have not submitter your app for review yet. But both of those channels are pretty responsive.
There are also a number of useful irc channels on irc.mozilla.org that you could use:
#openwebapps would probably be best place to ask about your issue
#marketplace also another good place to ask about marketplace issues
#app-reviewers any question about the review process
I hope that helps a bit. If you insist on getting an answer here, please provide the information I asked and a link to the zip file so I can take a look. Cheers!
I had the same message 2 days ago. I was confused, because it talked about manifest instead of manifest.webapp as usually documented as being required.
Uncertain about my understanding I copied my manifest.webapp to manifest and included it to my Zip.
Believe it or not, the Zip was accepted now.
Later I tried to verify the issue and removed the webapp, but now the Zip was still accepted as it should have been from the beginning.
Maybe, if nothing else helps you might give it a try.