Well I guess I should have posted sooner, because as usually happens once I post I find the answer.
I only stumbled upon this while using JSFiddle. I noticed that they had dependencies you can add, among them was the JavaScript port of libphonenumber (which I'd already tried to use). While it doesn't load correctly in JSFiddle because the connection is refused, the link still works to a minified version.
See here: Minified JavaScript of libphonenumber-js
Once I dropped this in place, and modified my code a bit, suddenly we're off to the races and everything is golden.
<script type="text/javascript" language="javascript" src="/static/js/libphonenumber-js.min.js"></script>
<script type="text/javascript">
$(".phone-format").keyup(function () {
var val_old = $(this).val();
var newString = new libphonenumber.AsYouType('US').input(val_old);
$(this).focus().val('').val(newString);
});
</script>
I'm really still curious if I just missed something in all the searching I've done over the last couple days, because I don't feel it should have been this difficult or require this much reverse engineering to be able to find this version of the package.
Oh well, hope this helps someone!
Answer from Chockomonkey on Stack OverflowUsing libphonenumber with JavaScript in HTML - Stack Overflow
Getting true valid number using asYouType in libphonenumber when its invalid
How to use libphonenumber-js node package to format dynamically phone numbers
angular - How to use Google libphonenumber in Typescript? - Stack Overflow
» npm install libphonenumber-js
» npm install google-libphonenumber
When dealing with CommonJS libraries, in TypeScript just like this google-libphonenumber, I'd like to suggest 2 ways about it (Tested by me and works well).
Initially, I'd like to suggest to install from NPM just like this: npm install --save google-libphonenumber.
Then, here we go both ways of using it:
1st Method
Just import it directly
import libphonenumber from 'google-libphonenumber';
class Something {
constructor() {//Just example, you can chose any method
const phoneUtil = libphonenumber.PhoneNumberUtil.getInstance();
console.log( phoneUtil.getSupportedRegions() );//It should works and give you some output
}
}
2nd Method
You still can make the power of Typescript typing or just use the existing one by: npm install --save-dev @types/google-libphonenumber.
Since you said that you using Angular, so you can declare that typing just installed at src/tsconfig.app.json ( I am using Angular Version 7 ). Here is an example I have made:
{
...
"compilerOptions": {
...
"types": [
"google-libphonenumber"
]
},
...
}
Then you can just import it like usual, in Typescript "typings" way like follow:
import { PhoneNumberUtil } from 'google-libphonenumber';
class Something {
constructor() {//Just example, you can chose any method
const phoneUtil: PhoneNumberUtil = PhoneNumberUtil.getInstance();
console.log( phoneUtil.getSupportedRegions() );//It should works and give you some output
}
}
you may either go with libphonenumber or google-libphonenumber as both of this library having a good number of installs also google-libphonenumber seems to be more powerful