I want to use Preview features of office-js Excel API (specifically DataValidation).
This page says that I should use Beta version of the library and they provide a link but I have no idea what to do with it.
What I did so far:
I have added the js path to index.html.
I copied types from ts file to file in node_modules.
But it doesn't seem like a good solution since whenever I update #types/office-js I would also have to copy source again...
If you are using angular follow these steps.
Refer to the beta office js cdn.
<script src="https://appsforoffice.microsoft.com/lib/beta/hosted/office.js" type="text/javascript"></script>
If you need type definition for beta version, install this.
npm install --save-dev #types/office-js-preview
If you were already using the production version, uninstall it:
npm uninstall --save-dev #types/office-js
Mention the following type in tsconfig.app.json like this (if types is already empty).
"types": ["office-js-preview"]
in order to use preview Api you only need:
Install latest insiders fast build, AND
refer to the BETA
CDN for office.js and if you will use typescript the typescript
library: here are the URLs you need to use, as Ricky suggests make sure you add those references to your HTML or JS files in your web app.
https://appsforoffice.microsoft.com/lib/beta/hosted/office.js
https://appsforoffice.microsoft.com/lib/beta/hosted/office.d.ts
Related
I understand that when we talk about the frontend we're talking about files being served to the browser of the person accessing my page. So, frontend javascript libraries are only javascript code that is being sent from my server to the browser.
So far everything is fine, what I don't understand is why npm has repositories for frontend libraries. Let's take this Leaflet example, I can install this library with npm using npm install leaflet -s. But what would be the purpose of doing that? I see that if I open Visual Studio Code and I declare this library with const leaflet = require('leaflet') then I can see its functions and documentation in a more clear way on the suggestions after typing leaflet.... I don't think that's the purpose of installing a library like Leaflet on Node.js though (since it works only on the frontend). What am I missing? Why would anyone install frontend only libraries on Node.js?
There are likely other reasons, but this is they reason I've done it and the reason I've seen other people do it: Many people use Node.js tooling to bundle/build webapps, so you might install your frontend dependencies, and then use rollup or webpack or browserify or TypeScript tooling or whatever to bundle it into a single .js file. Since you're likely already installing the tooling with npm, installing the libraries also with npm means you don't need some other tool to do it.
Additionally, people also use npm to install libraries for electron apps, cordova apps, React Native apps, etc. And these things can all use frontend libraries because they basically have a web view embedded. (To be honest, I'm not sure that's the case with React Native because I've never used it, but I assume it is.)
Since you mention Leaflet specifically, here is an example of someone using npm to install leaflet, and then using browserify to make it so that they can basically write Node.js code (including require('leaflet') and run it in the browser.
I use npm as a package manager for my web frontend projects. I have a need to generate some fake data locally within JavaScript in a project. Faker.js seems to be the perfect library to do so.
Most libraries, when I install them with npm, either have usable js files at the root of the installed files or provide a dist or similar folder with the .js files that I can reference, e.g. <script src="node_modules/angular/angular.min.js"></script> Faker.js however does not include this.
The documentation for faker simply includes this line: <script src = "faker.js" type = "text/javascript"></script> Clearly this will not work since the package doesn't even install a file called faker.js anywhere. My assumption is that you're expected to either use it with Node.js (non web frontend) projects or you're expected to build it somehow to get the faker.js file.
One tutorial I found online says you can npm install faker and then use <script src="node_modules/faker/build/build/faker.js">. But I also do not have a build folder. The tutorial didn't give any instructions on building the faker.js file.
Can someone shed some light on how this works? I have actually seen at least one other package (jQuery) that is similar and does not include a compiled usable browser version in the distribution. In past projects I've simply downloaded a compiled .js file and included it in my source control, but I'd like to try to avoid that if at all possible!
(Please don't answer with "just use a CDN" - I am working in an environment with specific policy requirements that HTML on the production server may not directly reference any off-site assets or scripts, but it is OK to pull in those libraries and self-host them. Frustrating, yes, but I don't get to make the rules.)
I've built a custom style "skin" on top of bootstrap that I intend to use in multiple UI projects.
Rather than copying/pasting the UI styles/components (built using sass and typescript in my current Angular 5 project), I want to build an NPM package that I can install these styles and components I've built in new projects, thus allowing updates to be done to the NPM package (maybe extending the controls within for example) without breaking the UI's using them or needing to update files within.
I've never setup an NPM project before. I've found a number of examples of how to build NPM packages, for example https://codeforgeek.com/2014/08/how-to-create-nodejs-npm-package/ but it seems to be for vanilla JS in this example. I need an example which:
Builds on a dependency, in this case bootstrap
Is to be used in Angular (I'm using version 5)
Is installable and updatable via NPM or maybe Yarn
Has anyone any top tips on achieving the above? Or any really clear guides where someone has done this before?
I realise this question is relatively broad but really I just need some pointers to get started and I will document the process further when I have a better understanding.
Thanks in advance!
So you should move your theme into a separate project. Then all you have to do is run npm init in that directory and you have a npm.
As for sharing it between projects, I would create a repo on Github for this theme npm. Push all of your changes there. Then you can reference it in the package.json of all your projects by linking to the Github repo. Here is a good Stack question about how to do that.
Finally, if you want to develop your theme locally inside one of your projects, you can use npm link. Here are he docs on that.
I have some Twitter functionality I'm working on and I want to use "Application-Only Authentication" which only needs my Twitter application credentials to just perform GETS in my app (e.g. random tweet searches based on user inputted tags, etc. - no actual user posting.)
Twitter supports this but most of the Twitter packages on Atmosphere and NPM do not. They force you to pass both application credentials and OAuth tokens, if you don't, your requests come back invalid. The most popular Meteor Twitter API package called mrt:twit actually wraps the NPM package ttezel/twit which actually implements Application-Only Authentication correctly, however the wrapper package for Meteor mrt:twit forces you to use Full Authentication requiring the user's OAuth tokens which I don't want or need to use. So I'd like to edit mrt:twit to properly follow ttezel/twit's interface.
However, the mrt:twit package is not on GitHub. How do I figure out where this lives and/or if I can access it locally and modify it and/or find some repository online for where it lives? Atmosphere doesn't offer much help providing no links from where this package is actually downloading?
Link for mrt:twit: https://atmospherejs.com/mrt/twit
Link for ttezel/twit: https://github.com/ttezel/twit
EDIT: I'm using Meteor 1.1.0.2. I was able to find where mrt:twit is locally. It's at:
.../.meteor/local/build/programs/server/packages/
After investigating, it's not that mrt:twit doesn't "implement" ttezel/twit's interface correctly, it's that mrt:twit is using/requiring an old version of ttezel/twit, version 1.1.9 instead of the current 2.1.0. That old version of ttezel/twit doesn't support the "application-only" authorization - I can see it in the code. Hence my above original issue. ttezel/twit downloads to the following folder:
.../.meteor/local/build/programs/server/npm/mrt_twit/node_modules/twit
Inside the above folder I see the full .git package for ttezel/twit but it's version 1.1.9. So I assume I could just replace this folder with the latest 2.1.0 version of ttezel/twit but I don't think you're supposed to have to mess with anything inside of an node_modules folder right? Shouldn't there be a config file somewhere to edit?
For the life of me I can't find where mrt:twit is declaring to use version 1.1.9. In all the code it just calls Npm.require('twit'). There's no config file I can find that sets the version to 1.1.9. The only thing I found is a file at the second path above sitting next to the twit folder called .node_version and all it has in it is v0.10.20 which is a version of Node to use I assume. That wouldn't "force" whatever package versions were out at that time would it? If so, then that's probably what is setting ttezel/twit to use 1.1.9.
My original post question still exists though, where can I find mrt:twit on a server so I can fork it/edit it and not have to edit the code locally?
I emailed the creators of Atmosphere (percolatestudio.com) and Tom was really helpful and pointed me to where mrt:twit lives on GitHub. It's on the old 1.0 atmosphere:
https://old-atmosphere.meteor.com/package/twit
And that page points to the actual GitHub location which is:
https://github.com/subhog/meteor-twit
So the above link is from where the current mrt:twit package downloads into your Meteor app if you add it to your app (as of this writing). Once I found that I could easily see in the package.js file it declares Npm.depends({twit: "1.1.9"}). On a side note: It would be nice if the current version of Atmosphere pointed you to the GitHub location of older/legacy packages how it does the new packages.
So I was able to fork this and update the package to use version 2.1.0 of ttezel/twit. I made a pull request for mrt:twit so hopefully the author updates it - as this is the number one Twitter API package for Meteor with 1,200 downloads. Seemed better to update it than to publish my own version.
Until then, I made a local package following the below link and everything is working great - including application-only authentication. Thanks for the comments - they were helpful. I'm still pretty new at Meteor and how the packaging system works.
http://www.webtempest.com/meteor-js-packages-tutorial
If you want to access the updated package I made it's at the below link but it's not a published meteor package - so you'll have to download it and use it locally:
https://github.com/evolross/meteor-twit
You should check .meteor/local/* folders.
I have a lot of packages files in .meteor/local/build/programs/server/packages
I'm afraid it's all compiled but you can grab some code you need and make your own package.
I am using Express with Jade and I installed backbone.js and jQuery via npm. Do I copy the appropriate js files into my public/javascript folder or will Jade understand if I use require() inside the view template file?
Please steer me in the right direction.
Thanks
Anything installed with the package manager is available by require(). If you're trying to use the libraries to be rendered client-side, then you shouldn't be installing them server-side.
As hexacyanide says, Anything installed with the package manager is available by require().
If you want to use packages installed via npm in the browser, you may want to take a look at browserify. Although I'd recommend to at first simply using the files provided on the backbone and jQuery websites. It's less to learn.
NPM is only for server side JavaScript packages.
If you want to manage your client side libraries with a package manager take a look at bower, which shares some concepts of NPM, but for the client side.