Skip to content

Add MIT License Headers to Components/Web.JS/**/*.ts Files #39164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Components/Web.JS/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"preclean": "yarn install --mutex network --frozen-lockfile",
"clean": "node node_modules/rimraf/bin.js ./dist/Debug ./dist/Release",
"prebuild": "yarn run clean && yarn install --mutex network --frozen-lockfile",
"lint": "eslint -c ./src/.eslintrc.js --ext .ts ./src",
"build": "yarn run build:debug && yarn run build:production",
"build:debug": "cd src && node ../node_modules/webpack-cli/bin/cli.js --mode development --config ./webpack.config.js",
"build:production": "cd src && node ../node_modules/webpack-cli/bin/cli.js --mode production --config ./webpack.config.js",
Expand All @@ -30,6 +31,7 @@
"@typescript-eslint/parser": "^4.29.3",
"babel-jest": "^27.1.0",
"eslint": "^7.32.0",
"eslint-plugin-header": "^3.1.1",
"inspectpack": "^4.7.1",
"jest": "^27.1.0",
"rimraf": "^3.0.2",
Expand Down
14 changes: 11 additions & 3 deletions src/Components/Web.JS/src/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
plugins: ['@typescript-eslint'],
plugins: ['@typescript-eslint', 'header'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
Expand Down Expand Up @@ -62,8 +62,16 @@ module.exports = {
"asyncArrow": "always"
}],
"space-in-parens": ["error", "never"],
"space-infix-ops": ["error"]

"space-infix-ops": ["error"],
"header/header": [
2,
"line",
[
" Licensed to the .NET Foundation under one or more agreements.",
" The .NET Foundation licenses this file to you under the MIT license."
],
2
]
},
globals: {
DotNet: "readonly"
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Web.JS/src/BinaryDecoder.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

const uint64HighPartShift = Math.pow(2, 32);
const maxSafeNumberHighPart = Math.pow(2, 21) - 1; // The high-order int32 from Number.MAX_SAFE_INTEGER

Expand Down
5 changes: 4 additions & 1 deletion src/Components/Web.JS/src/Boot.Server.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { DotNet } from '@microsoft/dotnet-js-interop';
import { Blazor } from './GlobalExports';
import { HubConnectionBuilder, HubConnection, HttpTransportType } from '@microsoft/signalr';
Expand Down Expand Up @@ -111,7 +114,7 @@ async function initializeConnection(options: CircuitStartOptions, logger: Logger
complete: () => controller.close(),
error: (err) => controller.error(err),
});
}
},
});

DotNet.jsCallDispatcher.supplyDotNetStream(streamId, readableStream);
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Web.JS/src/Boot.WebAssembly.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

/* eslint-disable array-element-newline */
import { DotNet } from '@microsoft/dotnet-js-interop';
import { Blazor } from './GlobalExports';
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Web.JS/src/Boot.WebView.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { DotNet } from '@microsoft/dotnet-js-interop';
import { Blazor } from './GlobalExports';
import { shouldAutoStart } from './BootCommon';
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Web.JS/src/BootCommon.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// Tells you if the script was added without <script src="..." autostart="false"></script>
export function shouldAutoStart(): boolean {
return !!(document &&
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Web.JS/src/BootErrors.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

let hasFailed = false;

export function showErrorNotification(): void {
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Web.JS/src/DomWrapper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import '@microsoft/dotnet-js-interop';

export const domFunctions = {
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Web.JS/src/Environment.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// Expose an export called 'platform' of the interface type 'Platform',
// so that consumers can be agnostic about which implementation they use.
// Basic alternative to having an actual DI container.
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Web.JS/src/GlobalExports.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { navigateTo, internalFunctions as navigationManagerInternalFunctions, NavigationOptions } from './Services/NavigationManager';
import { domFunctions } from './DomWrapper';
import { Virtualize } from './Virtualize';
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Web.JS/src/InputFile.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

export const InputFile = {
init,
toImageFile,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { BootJsonData } from "../Platform/BootConfig";
import { CircuitStartOptions } from "../Platform/Circuits/CircuitStartOptions";
import { JSInitializer } from "./JSInitializers";
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { BootJsonData } from '../Platform/BootConfig';
import { CircuitStartOptions } from '../Platform/Circuits/CircuitStartOptions';
import { JSInitializer } from './JSInitializers';

export async function fetchAndInvokeInitializers(options: Partial<CircuitStartOptions>) : Promise<JSInitializer> {
const jsInitializersResponse = await fetch('_blazor/initializers', {
method: 'GET',
credentials: 'include',
cache: 'no-cache'
cache: 'no-cache',
});

const initializers: string[] = await jsInitializersResponse.json();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { BootJsonData } from "../Platform/BootConfig";
import { WebAssemblyStartOptions } from "../Platform/WebAssemblyStartOptions";
import { JSInitializer } from "./JSInitializers";
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { BootJsonData } from '../Platform/BootConfig';
import { WebAssemblyStartOptions } from '../Platform/WebAssemblyStartOptions';
import { JSInitializer } from './JSInitializers';

export async function fetchAndInvokeInitializers(bootConfig: BootJsonData, options: Partial<WebAssemblyStartOptions>) : Promise<JSInitializer> {
const initializers = bootConfig.resources.libraryInitializers;
const jsInitializer = new JSInitializer();
if (initializers) {
await jsInitializer.importInitializersAsync(
Object.keys(initializers),
[options, bootConfig.resources.extensions]);
[options, bootConfig.resources.extensions]
);
}

return jsInitializer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { JSInitializer } from './JSInitializers';

export async function fetchAndInvokeInitializers() : Promise<JSInitializer> {
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Web.JS/src/JSInitializers/JSInitializers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { Blazor } from '../GlobalExports';

type BeforeBlazorStartedCallback = (...args: unknown[]) => Promise<void>;
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Web.JS/src/PageTitle.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { getLogicalParent, LogicalElement } from './Rendering/LogicalElements';

export const PageTitle = {
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Web.JS/src/Platform/BootConfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { WebAssemblyBootResourceType } from './WebAssemblyStartOptions';

type LoadBootResourceCallback = (type: WebAssemblyBootResourceType, name: string, defaultUri: string, integrity: string) => string | Promise<Response> | null | undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { internalFunctions as navigationManagerFunctions } from '../../Services/NavigationManager';
import { toLogicalRootCommentElement, LogicalElement, toLogicalElement } from '../../Rendering/LogicalElements';
import { ServerComponentDescriptor } from '../../Services/ComponentDescriptorDiscovery';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { LogLevel } from '../Logging/Logger';
import { HubConnectionBuilder } from '@microsoft/signalr';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { HubConnection } from '@microsoft/signalr';
import { getNextChunk } from '../../StreamingInterop';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { ReconnectDisplay } from './ReconnectDisplay';
import { Logger, LogLevel } from '../Logging/Logger';
import { Blazor } from '../../GlobalExports';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { ReconnectionHandler, ReconnectionOptions } from './CircuitStartOptions';
import { ReconnectDisplay } from './ReconnectDisplay';
import { DefaultReconnectDisplay } from './DefaultReconnectDisplay';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

export interface ReconnectDisplay {
show(): void;
update(currentAttempt: number): void;
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Web.JS/src/Platform/Circuits/RenderQueue.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { renderBatch } from '../../Rendering/Renderer';
import { OutOfProcessRenderBatch } from '../../Rendering/RenderBatch/OutOfProcessRenderBatch';
import { Logger, LogLevel } from '../Logging/Logger';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { ReconnectDisplay } from './ReconnectDisplay';
export class UserSpecifiedDisplay implements ReconnectDisplay {
static readonly ShowClassName = 'components-reconnect-show';
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Web.JS/src/Platform/Logging/Loggers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

/* eslint-disable no-console */

import { Logger, LogLevel } from './Logger';
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Web.JS/src/Platform/Mono/MonoDebugger.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { WebAssemblyResourceLoader } from '../WebAssemblyResourceLoader';

const currentBrowserIsChrome = (window as any).chrome
Expand Down
4 changes: 3 additions & 1 deletion src/Components/Web.JS/src/Platform/Mono/MonoPlatform.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable @typescript-eslint/ban-types */
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

/* eslint-disable no-prototype-builtins */
import { DotNet } from '@microsoft/dotnet-js-interop';
import { attachDebuggerHotkey, hasDebuggingEnabled } from './MonoDebugger';
Expand Down
5 changes: 4 additions & 1 deletion src/Components/Web.JS/src/Platform/Mono/MonoTypes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { Pointer, System_String, System_Array, System_Object } from '../Platform';

// Mono uses this global to hang various debugging-related items on
Expand All @@ -14,7 +17,7 @@ declare interface MONO {
// Mono uses this global to hold low-level interop APIs
declare interface BINDING {
mono_obj_array_new(length: number): System_Array<System_Object>;
mono_obj_array_set(array: System_Array<System_Object>, index: Number, value: System_Object): void;
mono_obj_array_set(array: System_Array<System_Object>, index: number, value: System_Object): void;
js_string_to_mono_string(jsString: string): System_String;
js_typed_array_to_array(array: Uint8Array): System_Object;
js_to_mono_obj(jsObject: any) : System_Object;
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Web.JS/src/Platform/Platform.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { WebAssemblyResourceLoader } from './WebAssemblyResourceLoader';

export interface Platform {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { LogicalElement, toLogicalRootCommentElement } from '../Rendering/LogicalElements';
import { WebAssemblyComponentDescriptor } from '../Services/ComponentDescriptorDiscovery';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { BootConfigResult } from './BootConfig';
import { System_String, System_Object } from './Platform';
import { Blazor } from '../GlobalExports';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { toAbsoluteUri } from '../Services/NavigationManager';
import { BootJsonData, ResourceList } from './BootConfig';
import { WebAssemblyStartOptions, WebAssemblyBootResourceType } from './WebAssemblyStartOptions';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

export interface WebAssemblyStartOptions {
/**
* Overrides the built-in boot resource loading mechanism so that boot resources can be fetched
Expand Down
11 changes: 7 additions & 4 deletions src/Components/Web.JS/src/Platform/WebView/WebViewIpcCommon.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

const ipcMessagePrefix = '__bwv:';
let applicationIsTerminated = false;

Expand All @@ -18,10 +21,10 @@ export function tryDeserializeMessage(message: string): IpcMessage | null {
}

export function setApplicationIsTerminated() {
// If there's an unhandled exception, we'll prevent the webview from doing anything else until
// it reloads the page. This is equivalent to what happens in Blazor Server, and avoids anyone
// taking a dependency on being able to continue interacting after a fatal error.
applicationIsTerminated = true;
// If there's an unhandled exception, we'll prevent the webview from doing anything else until
// it reloads the page. This is equivalent to what happens in Blazor Server, and avoids anyone
// taking a dependency on being able to continue interacting after a fatal error.
applicationIsTerminated = true;
}

interface IpcMessage {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { DotNet } from '@microsoft/dotnet-js-interop';
import { showErrorNotification } from '../../BootErrors';
import { OutOfProcessRenderBatch } from '../../Rendering/RenderBatch/OutOfProcessRenderBatch';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { trySerializeMessage } from './WebViewIpcCommon';

export function sendAttachPage(baseUrl: string, startUrl: string) {
Expand Down Expand Up @@ -26,7 +29,7 @@ function base64EncodeByteArray(data: Uint8Array) {
// Note `btoa(String.fromCharCode.apply(null, data as unknown as number[]));`
// isn't sufficient as the `apply` over a large array overflows the stack.
const charBytes = new Array(data.length);
for (var i = 0; i < data.length; i++) {
for (let i = 0; i < data.length; i++) {
charBytes[i] = String.fromCharCode(data[i]);
}
const dataBase64Encoded = btoa(charBytes.join(''));
Expand Down
4 changes: 4 additions & 0 deletions src/Components/Web.JS/src/Rendering/BrowserRenderer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { RenderBatch, ArrayBuilderSegment, RenderTreeEdit, RenderTreeFrame, EditType, FrameType, ArrayValues } from './RenderBatch/RenderBatch';
import { EventDelegator } from './Events/EventDelegator';
import { LogicalElement, PermutationListEntry, toLogicalElement, insertLogicalChild, removeLogicalChild, getLogicalParent, getLogicalChild, createAndInsertLogicalContainer, isSvgElement, getLogicalChildrenArray, getLogicalSiblingEnd, permuteLogicalChildren, getClosestDomElement, emptyLogicalElement } from './LogicalElements';
Expand All @@ -15,6 +18,7 @@ export class BrowserRenderer {
public eventDelegator: EventDelegator;

private rootComponentIds = new Set<number>();

private childComponentLocations: { [componentId: number]: LogicalElement } = {};

public constructor(browserRendererId: number) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

import { DotNet } from '@microsoft/dotnet-js-interop';

export function applyCaptureIdToElement(element: Element, referenceCaptureId: string) {
Expand Down
Loading