-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
2,490 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<markdown [data]="(readme | async) || ''" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {CommonModule} from '@angular/common'; | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
import {MarkdownModule} from 'ngx-markdown'; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: 'platform-page', | ||
imports: [CommonModule, MarkdownModule], | ||
templateUrl: './index.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export default class CommonPage { | ||
protected readonly readme = import( | ||
'../../../../../../libs/platform/README.md?raw' | ||
).then((a) => a.default.replace('![logo](logo.svg) ', '')) as any as Promise<string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# ![ng-web-apis logo](https://raw.githubusercontent.com/taiga-family/ng-web-apis/main/libs/platform/logo.svg) Platform | ||
|
||
## Install | ||
|
||
```bash | ||
npm i @ng-web-apis/platform | ||
``` | ||
|
||
## Examples | ||
|
||
`isArray` | ||
|
||
```ts | ||
expect(isArray([])).toBeTruthy(); | ||
expect(isArray(new Array())).toBeTruthy(); | ||
``` | ||
|
||
`toArray` | ||
|
||
```ts | ||
expect(toArray(1)).toEqual([1]); | ||
expect(toArray([1])).toEqual([1]); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Karma configuration file, see link for more information | ||
// https://karma-runner.github.io/1.0/config/configuration-file.html | ||
|
||
module.exports = function (config) { | ||
config.set({ | ||
basePath: '', | ||
frameworks: ['jasmine', '@angular-devkit/build-angular'], | ||
plugins: [ | ||
require('karma-jasmine'), | ||
require('karma-chrome-launcher'), | ||
require('karma-jasmine-html-reporter'), | ||
require('@angular-devkit/build-angular/plugins/karma'), | ||
require('karma-coverage'), | ||
], | ||
client: { | ||
clearContext: true, // leave Jasmine Spec Runner output visible in browser | ||
}, | ||
preprocessors: { | ||
'src/**/*.js': ['coverage'], | ||
}, | ||
coverageReporter: { | ||
type: 'html', | ||
dir: require('node:path').join(__dirname, '../../coverage/payment-request'), | ||
}, | ||
reporters: ['progress', 'kjhtml'], | ||
port: 9876, | ||
colors: true, | ||
logLevel: config.LOG_INFO, | ||
autoWatch: true, | ||
browsers: ['ChromeHeadless'], | ||
singleRun: true, | ||
customLaunchers: { | ||
ChromeHeadless: { | ||
base: 'Chrome', | ||
flags: [ | ||
'--no-sandbox', | ||
'--headless', | ||
'--disable-gpu', | ||
'--disable-web-security', | ||
'--remote-debugging-port=9222', | ||
], | ||
}, | ||
}, | ||
}); | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json", | ||
"assets": [ | ||
"logo.svg", | ||
"README.md" | ||
], | ||
"dest": "../../dist/platform", | ||
"lib": { | ||
"entryFile": "src/index.ts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "@ng-web-apis/platfrorm", | ||
"version": "4.6.5", | ||
"description": "A basic library for web apis", | ||
"keywords": [ | ||
"angular", | ||
"ng", | ||
"web", | ||
"platform" | ||
], | ||
"homepage": "https://github.com/taiga-family/ng-web-apis/blob/main/libs/platform/README.md", | ||
"bugs": "https://github.com/taiga-family/ng-web-apis/issues", | ||
"repository": "https://github.com/taiga-family/ng-web-apis", | ||
"license": "Apache-2.0", | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"name": "platform", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/platform", | ||
"projectType": "library", | ||
"targets": { | ||
"test": { | ||
"executor": "@angular-devkit/build-angular:karma", | ||
"outputs": ["{workspaceRoot}/coverage/{projectName}"], | ||
"options": { | ||
"main": "libs/{projectName}/test.ts", | ||
"tsConfig": "tsconfig.spec.json", | ||
"karmaConfig": "libs/{projectName}/karma.conf.js", | ||
"codeCoverage": true, | ||
"browsers": "ChromeHeadless" | ||
} | ||
}, | ||
"build": { | ||
"executor": "@nx/rollup:rollup", | ||
"outputs": ["{workspaceRoot}/dist/{projectName}"], | ||
"options": { | ||
"project": "{projectRoot}/package.json", | ||
"outputPath": "dist/{projectName}", | ||
"entryFile": "{projectRoot}/src/index.ts", | ||
"tsConfig": "{projectRoot}/tsconfig.lib.json", | ||
"format": ["esm", "cjs"], | ||
"compiler": "tsc", | ||
"external": "all", | ||
"assets": [ | ||
{ | ||
"glob": "{projectRoot}/README.md", | ||
"input": ".", | ||
"output": "." | ||
} | ||
] | ||
} | ||
}, | ||
"publish": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"parallel": false, | ||
"commands": ["cp ./LICENSE ./dist/{projectName}", "npm publish ./dist/{projectName} --ignore-scripts"] | ||
}, | ||
"dependsOn": [ | ||
{ | ||
"target": "build", | ||
"params": "ignore", | ||
"dependencies": false | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './is-ios'; | ||
export * from './is-apple'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* @description: | ||
* All Chrome / Chromium-based browsers will return MacIntel on macOS, | ||
* no matter what the hardware architecture is. See the source code here: | ||
* https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/frame/navigator_id.cc;l=64;drc=703d3c472cf27470dad21a3f2c8972aca3732cd6 | ||
* But maybe in future years, it will be changed to MacM1 | ||
* | ||
* Documentation: | ||
* https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform | ||
*/ | ||
export function isApple(navigator: Navigator): boolean { | ||
return navigator.platform.startsWith('Mac') || navigator.platform === 'iPhone'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {isApple} from './is-apple'; | ||
|
||
const IOS_REG_EXP = /ipad|iphone|ipod/; | ||
|
||
export function isIos(navigator: Navigator): boolean { | ||
return ( | ||
IOS_REG_EXP.test(navigator.userAgent.toLowerCase()) || | ||
(isApple(navigator) && navigator.maxTouchPoints > 1) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'zone.js'; | ||
import 'zone.js/testing'; | ||
|
||
import {getTestBed} from '@angular/core/testing'; | ||
import { | ||
BrowserDynamicTestingModule, | ||
platformBrowserDynamicTesting, | ||
} from '@angular/platform-browser-dynamic/testing'; | ||
|
||
getTestBed().initTestEnvironment( | ||
BrowserDynamicTestingModule, | ||
platformBrowserDynamicTesting(), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": "../../tsconfig.build.json", | ||
"files": ["src/index.ts"], | ||
"include": ["src/*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.spec.json", | ||
"include": ["**/*.spec.ts", "test.ts", "**/*.d.ts"] | ||
} |
Oops, something went wrong.