mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
chore: cleanup
This commit is contained in:
4
packages/core/file-system/index.d.ts
vendored
4
packages/core/file-system/index.d.ts
vendored
@ -73,7 +73,7 @@ export class FileSystemEntity {
|
||||
/**
|
||||
* Contains Android-specific the file system helpers.
|
||||
*/
|
||||
class Android {
|
||||
declare class Android {
|
||||
createFile(options: { relativePath?: string; name: string; mime: string; directory: AndroidDirectory }): File;
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ class Android {
|
||||
* Contains iOS-specific the file system helpers.
|
||||
*/
|
||||
|
||||
class iOS {}
|
||||
declare class iOS {}
|
||||
|
||||
/**
|
||||
* Represents a File entity on the file system.
|
||||
|
4
packages/core/http/http-request/index.d.ts
vendored
4
packages/core/http/http-request/index.d.ts
vendored
@ -1,3 +1,7 @@
|
||||
import { HttpRequestOptions, HttpResponse, Headers } from '../http-interfaces';
|
||||
/**
|
||||
* Makes a generic http request using the provided options and returns a HttpResponse Object.
|
||||
* @param options An object that specifies various request options.
|
||||
*/
|
||||
export const request: (options: HttpRequestOptions) => Promise<HttpResponse>;
|
||||
export function addHeader(headers: Headers, key: string, value: string): void;
|
||||
|
109
packages/core/http/index.d.ts
vendored
109
packages/core/http/index.d.ts
vendored
@ -1,4 +1,7 @@
|
||||
import type { ImageSource } from '../image-source';
|
||||
import type { File } from '../file-system';
|
||||
import type { ImageSource } from '../image-source';
|
||||
import type { HttpResponse, HttpRequestOptions } from './http-interfaces';
|
||||
export { request } from './http-request';
|
||||
export * from './http-interfaces';
|
||||
|
||||
/**
|
||||
@ -42,7 +45,7 @@ export function getImage(options: HttpRequestOptions): Promise<ImageSource>;
|
||||
* @param url The URL to request from.
|
||||
* @param destinationFilePath Optional. The downloaded file path.
|
||||
*/
|
||||
export function getFile(url: string, destinationFilePath?: string): Promise<File>;
|
||||
export function getFile(url: string, destinationFilePath?: string): Promise<any>;
|
||||
|
||||
/**
|
||||
* Downloads the content from the specified URL and attempts to save it as file.
|
||||
@ -62,105 +65,3 @@ export function getBinary(url: string): Promise<ArrayBuffer>;
|
||||
* @param options An object that specifies various request options.
|
||||
*/
|
||||
export function getBinary(options: HttpRequestOptions): Promise<ArrayBuffer>;
|
||||
|
||||
/**
|
||||
* Makes a generic http request using the provided options and returns a HttpResponse Object.
|
||||
* @param options An object that specifies various request options.
|
||||
*/
|
||||
export function request(options: HttpRequestOptions): Promise<HttpResponse>;
|
||||
|
||||
/**
|
||||
* Provides options for the http requests.
|
||||
*/
|
||||
export interface HttpRequestOptions {
|
||||
/**
|
||||
* Gets or sets the request url.
|
||||
*/
|
||||
url: string;
|
||||
|
||||
/**
|
||||
* Gets or sets the request method.
|
||||
*/
|
||||
method: string;
|
||||
|
||||
/**
|
||||
* Gets or sets the request headers in JSON format.
|
||||
*/
|
||||
headers?: any;
|
||||
|
||||
/**
|
||||
* Gets or sets the request body.
|
||||
*/
|
||||
content?: string | FormData | ArrayBuffer;
|
||||
|
||||
/**
|
||||
* Gets or sets the request timeout in milliseconds.
|
||||
*/
|
||||
timeout?: number;
|
||||
|
||||
/**
|
||||
* Gets or sets wether to *not* follow server's redirection responses.
|
||||
*/
|
||||
dontFollowRedirects?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encapsulates HTTP-response information from an HTTP-request.
|
||||
*/
|
||||
export interface HttpResponse {
|
||||
/**
|
||||
* Gets the response status code.
|
||||
*/
|
||||
statusCode: number;
|
||||
|
||||
/**
|
||||
* Gets the response headers.
|
||||
*/
|
||||
headers: Headers;
|
||||
|
||||
/**
|
||||
* Gets the response content.
|
||||
*/
|
||||
content?: HttpContent;
|
||||
}
|
||||
|
||||
export type Headers = { [key: string]: string | string[] };
|
||||
|
||||
export enum HttpResponseEncoding {
|
||||
UTF8,
|
||||
GBK,
|
||||
}
|
||||
/**
|
||||
* Encapsulates the content of an HttpResponse.
|
||||
*/
|
||||
export interface HttpContent {
|
||||
/**
|
||||
* Gets the response body as raw data.
|
||||
*/
|
||||
raw: any;
|
||||
|
||||
/**
|
||||
* Gets the response body as ArrayBuffer
|
||||
*/
|
||||
toArrayBuffer: () => ArrayBuffer;
|
||||
|
||||
/**
|
||||
* Gets the response body as string.
|
||||
*/
|
||||
toString: (encoding?: HttpResponseEncoding) => string;
|
||||
|
||||
/**
|
||||
* Gets the response body as JSON object.
|
||||
*/
|
||||
toJSON: (encoding?: HttpResponseEncoding) => any;
|
||||
|
||||
/**
|
||||
* Gets the response body as ImageSource.
|
||||
*/
|
||||
toImage: () => Promise<ImageSource>;
|
||||
|
||||
/**
|
||||
* Gets the response body as file.
|
||||
*/
|
||||
toFile: (destinationFilePath?: string) => any /* File */;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { setGetImageRequest, type ImageSourceLike } from './http-shared';
|
||||
import { request } from './http-request';
|
||||
export * from './http-request';
|
||||
export { request } from './http-request';
|
||||
export * from './http-interfaces';
|
||||
|
||||
export function getString(arg: any): Promise<string> {
|
||||
|
12
packages/core/index.d.ts
vendored
12
packages/core/index.d.ts
vendored
@ -11,12 +11,11 @@ export * from './application';
|
||||
export { androidRegisterBroadcastReceiver, androidUnregisterBroadcastReceiver, androidRegisteredReceivers, iosAddNotificationObserver, iosRemoveNotificationObserver, iosNotificationObservers } from './application/helpers';
|
||||
export { getNativeApp, setNativeApp } from './application/helpers-common';
|
||||
export * as ApplicationSettings from './application-settings';
|
||||
import * as Accessibility from './accessibility';
|
||||
export namespace AccessibilityEvents {
|
||||
export const accessibilityBlurEvent = Accessibility.accessibilityBlurEvent;
|
||||
export const accessibilityFocusEvent = Accessibility.accessibilityFocusEvent;
|
||||
export const accessibilityFocusChangedEvent = Accessibility.accessibilityFocusChangedEvent;
|
||||
export const accessibilityPerformEscapeEvent = Accessibility.accessibilityPerformEscapeEvent;
|
||||
export const accessibilityBlurEvent: 'accessibilityBlur';
|
||||
export const accessibilityFocusEvent: 'accessibilityFocus';
|
||||
export const accessibilityFocusChangedEvent: 'accessibilityFocusChanged';
|
||||
export const accessibilityPerformEscapeEvent: 'accessibilityPerformEscape';
|
||||
}
|
||||
export { AccessibilityLiveRegion, AccessibilityRole, AccessibilityState, AccessibilityTrait, FontScaleCategory } from './accessibility';
|
||||
export { Color } from './color';
|
||||
@ -37,7 +36,8 @@ export type { PropertyChangeData, EventData, EventDataValue } from './data/obser
|
||||
export { VirtualArray } from './data/virtual-array';
|
||||
export type { ItemsLoading } from './data/virtual-array';
|
||||
export { File, FileSystemEntity, Folder, knownFolders, path, getFileAccess, AndroidDirectory } from './file-system';
|
||||
export type { HttpRequestOptions, HttpResponse, Headers, HttpResponseEncoding, HttpContent } from './http';
|
||||
export type { HttpRequestOptions, HttpResponse, Headers, HttpContent } from './http/http-interfaces';
|
||||
export { HttpResponseEncoding } from './http/http-interfaces';
|
||||
export * as Http from './http';
|
||||
export { ImageAsset } from './image-asset';
|
||||
export type { ImageAssetOptions } from './image-asset';
|
||||
|
@ -26,7 +26,8 @@ export type { PropertyChangeData, EventData } from './data/observable';
|
||||
export { VirtualArray } from './data/virtual-array';
|
||||
export type { ItemsLoading } from './data/virtual-array';
|
||||
export { File, FileSystemEntity, Folder, knownFolders, path, getFileAccess, AndroidDirectory } from './file-system';
|
||||
export type { HttpRequestOptions, HttpResponse, Headers, HttpResponseEncoding, HttpContent } from './http';
|
||||
export type { HttpRequestOptions, HttpResponse, Headers, HttpContent } from './http/http-interfaces';
|
||||
export { HttpResponseEncoding } from './http/http-interfaces';
|
||||
export * as Http from './http';
|
||||
export { ImageAsset } from './image-asset';
|
||||
export type { ImageAssetOptions } from './image-asset';
|
||||
|
@ -4,9 +4,17 @@
|
||||
"sourceRoot": "packages/core",
|
||||
"projectType": "library",
|
||||
"generators": {},
|
||||
"namedInputs": { "default": ["{projectRoot}/**/*"], "production": ["!{projectRoot}/**/*.spec.ts"] },
|
||||
"namedInputs": {
|
||||
"default": ["{projectRoot}/**/*"],
|
||||
"production": ["!{projectRoot}/**/*.spec.ts"]
|
||||
},
|
||||
"targets": {
|
||||
"lint": { "executor": "@nx/eslint:lint", "options": { "lintFilePatterns": ["packages/core/**/*.ts", "packages/core/references.d.ts", "packages/core/**/*.spec.ts", "packages/core/**/*.spec.tsx", "packages/core/**/*.spec.js", "packages/core/**/*.spec.jsx", "packages/core/**/*.d.ts"] } },
|
||||
"lint": {
|
||||
"executor": "@nx/eslint:lint",
|
||||
"options": {
|
||||
"lintFilePatterns": ["packages/core/**/*.ts", "packages/core/references.d.ts", "packages/core/**/*.spec.ts", "packages/core/**/*.spec.tsx", "packages/core/**/*.spec.js", "packages/core/**/*.spec.jsx", "packages/core/**/*.d.ts"]
|
||||
}
|
||||
},
|
||||
"build": {
|
||||
"executor": "@nx/js:tsc",
|
||||
"inputs": ["default", "^production"],
|
||||
@ -16,11 +24,41 @@
|
||||
"outputPath": "{workspaceRoot}/dist/packages/core",
|
||||
"rootDir": "{projectRoot}",
|
||||
"main": "{projectRoot}/index.ts",
|
||||
"assets": ["{workspaceRoot}/LICENSE", "{projectRoot}/README.md", "{projectRoot}/global-types.d.ts", "{projectRoot}/fetch/LICENSE", { "glob": "**/*", "input": "{projectRoot}/js-libs/", "output": "./js-libs/" }, { "glob": "**/*", "input": "{projectRoot}/cli-hooks/", "output": "./cli-hooks/" }, { "glob": "**/*", "input": "{projectRoot}/platforms/", "output": "./platforms/" }, { "glob": "**/*.d.ts", "input": "{projectRoot}/", "output": "./" }]
|
||||
"assets": [
|
||||
"{workspaceRoot}/LICENSE",
|
||||
"{projectRoot}/README.md",
|
||||
"{projectRoot}/global-types.d.ts",
|
||||
"{projectRoot}/fetch/LICENSE",
|
||||
{
|
||||
"glob": "**/*",
|
||||
"input": "{projectRoot}/js-libs/",
|
||||
"output": "./js-libs/"
|
||||
},
|
||||
{
|
||||
"glob": "**/*",
|
||||
"input": "{projectRoot}/cli-hooks/",
|
||||
"output": "./cli-hooks/"
|
||||
},
|
||||
{
|
||||
"glob": "**/*",
|
||||
"input": "{projectRoot}/platforms/",
|
||||
"output": "./platforms/"
|
||||
},
|
||||
{
|
||||
"glob": "**/*.d.ts",
|
||||
"input": "{projectRoot}/",
|
||||
"output": "./"
|
||||
}
|
||||
]
|
||||
},
|
||||
"dependsOn": ["^build"]
|
||||
},
|
||||
"build.npm": { "executor": "nx:run-commands", "options": { "commands": ["node tools/scripts/build-finish.ts core"], "parallel": false }, "outputs": ["{workspaceRoot}/dist/packages/core"], "dependsOn": [{ "target": "build" }] },
|
||||
"test": { "executor": "@nx/vite:test", "outputs": ["{options.reportsDirectory}"], "options": { "reportsDirectory": "../../coverage/packages/core" } }
|
||||
"test": {
|
||||
"executor": "@nx/vite:test",
|
||||
"outputs": ["{options.reportsDirectory}"],
|
||||
"options": {
|
||||
"reportsDirectory": "../../coverage/packages/core"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
||||
import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
|
||||
import { fileURLToPath, URL } from 'node:url';
|
||||
|
||||
export default defineConfig({
|
||||
root: __dirname,
|
||||
@ -13,6 +14,10 @@ export default defineConfig({
|
||||
// },
|
||||
resolve: {
|
||||
extensions: ['.ts', '.ios.ts'],
|
||||
alias: {
|
||||
// ‘~’ at import root → /absolute/path/to/src
|
||||
'~': fileURLToPath(new URL('./', import.meta.url)),
|
||||
},
|
||||
},
|
||||
test: {
|
||||
watch: false,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { HttpRequestOptions, HttpResponse } from '../http';
|
||||
import type { HttpRequestOptions, HttpResponse } from '../http/http-interfaces';
|
||||
import { request } from '../http';
|
||||
import { isString, isFunction } from '../utils/types';
|
||||
import { Trace } from '../trace';
|
||||
|
@ -1,30 +0,0 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const { serializeJson, parseJson } = require('@nx/devkit');
|
||||
|
||||
const rootDir = path.resolve(path.join(__dirname, '..', '..'));
|
||||
|
||||
const cmdArgs = process.argv.slice(2);
|
||||
const packageName = cmdArgs[0];
|
||||
const publish = cmdArgs[1] === 'publish';
|
||||
|
||||
const packagePath = path.join('packages', packageName, 'package.json');
|
||||
const packageJson = JSON.parse(fs.readFileSync(packagePath));
|
||||
const npmPackageName = packageJson.name;
|
||||
console.log(`Building ${npmPackageName}...${publish ? 'and publishing.' : ''}`);
|
||||
|
||||
// function cleanPackage() {
|
||||
// // helps remove unwanted properties which may be added by other tooling
|
||||
// const packageJsonPath = path.resolve(rootDir, 'dist', 'packages', packageName, 'package.json');
|
||||
// let packageJson = fs.readFileSync(packageJsonPath, { encoding: 'utf-8' });
|
||||
// if (packageJson) {
|
||||
// packageJson = parseJson(packageJson);
|
||||
// // we don't need module or type properties at the moment
|
||||
// delete packageJson['module'];
|
||||
// delete packageJson['type'];
|
||||
// fs.writeFileSync(packageJsonPath, serializeJson(packageJson));
|
||||
// }
|
||||
// }
|
||||
|
||||
// cleanPackage();
|
||||
console.log(`${npmPackageName} ready to publish.`);
|
Reference in New Issue
Block a user