piral-blazor 1.0.0-pre.2217 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +55 -12
- package/convert.d.ts +13 -10
- package/convert.js +17 -12
- package/esm/converter.d.ts +10 -6
- package/esm/converter.js +164 -48
- package/esm/converter.js.map +1 -1
- package/esm/create.d.ts +21 -1
- package/esm/create.js +29 -15
- package/esm/create.js.map +1 -1
- package/esm/dependencies.d.ts +6 -3
- package/esm/dependencies.js +104 -14
- package/esm/dependencies.js.map +1 -1
- package/esm/events.d.ts +6 -0
- package/esm/events.js +145 -0
- package/esm/events.js.map +1 -0
- package/esm/interop.d.ts +29 -0
- package/esm/interop.js +205 -0
- package/esm/interop.js.map +1 -0
- package/esm/navigation.d.ts +2 -0
- package/esm/navigation.js +30 -0
- package/esm/navigation.js.map +1 -0
- package/esm/types.d.ts +97 -4
- package/infra.codegen +53 -68
- package/lib/converter.d.ts +10 -6
- package/lib/converter.js +164 -48
- package/lib/converter.js.map +1 -1
- package/lib/create.d.ts +21 -1
- package/lib/create.js +31 -17
- package/lib/create.js.map +1 -1
- package/lib/dependencies.d.ts +6 -3
- package/lib/dependencies.js +104 -14
- package/lib/dependencies.js.map +1 -1
- package/lib/events.d.ts +6 -0
- package/lib/events.js +154 -0
- package/lib/events.js.map +1 -0
- package/lib/index.js +1 -1
- package/lib/interop.d.ts +29 -0
- package/lib/interop.js +226 -0
- package/lib/interop.js.map +1 -0
- package/lib/navigation.d.ts +2 -0
- package/lib/navigation.js +35 -0
- package/lib/navigation.js.map +1 -0
- package/lib/types.d.ts +97 -4
- package/package.json +26 -13
- package/src/converter.ts +237 -57
- package/src/create.ts +53 -9
- package/src/dependencies.ts +122 -14
- package/src/events.ts +174 -0
- package/src/interop.ts +273 -0
- package/src/navigation.ts +36 -0
- package/src/types.ts +115 -4
- package/convert.ts +0 -17
- package/esm/internal/Environment.d.ts +0 -3
- package/esm/internal/Environment.js +0 -6
- package/esm/internal/Environment.js.map +0 -1
- package/esm/internal/Platform/BootConfig.d.ts +0 -20
- package/esm/internal/Platform/BootConfig.js +0 -10
- package/esm/internal/Platform/BootConfig.js.map +0 -1
- package/esm/internal/Platform/Mono/MonoDebugger.d.ts +0 -3
- package/esm/internal/Platform/Mono/MonoDebugger.js +0 -43
- package/esm/internal/Platform/Mono/MonoDebugger.js.map +0 -1
- package/esm/internal/Platform/Mono/MonoPlatform.d.ts +0 -2
- package/esm/internal/Platform/Mono/MonoPlatform.js +0 -403
- package/esm/internal/Platform/Mono/MonoPlatform.js.map +0 -1
- package/esm/internal/Platform/Mono/TimezoneDataFile.d.ts +0 -1
- package/esm/internal/Platform/Mono/TimezoneDataFile.js +0 -51
- package/esm/internal/Platform/Mono/TimezoneDataFile.js.map +0 -1
- package/esm/internal/Platform/Platform.d.ts +0 -31
- package/esm/internal/Platform/Platform.js +0 -2
- package/esm/internal/Platform/Platform.js.map +0 -1
- package/esm/internal/Platform/Url.d.ts +0 -2
- package/esm/internal/Platform/Url.js +0 -11
- package/esm/internal/Platform/Url.js.map +0 -1
- package/esm/internal/Platform/WebAssemblyConfigLoader.d.ts +0 -4
- package/esm/internal/Platform/WebAssemblyConfigLoader.js +0 -64
- package/esm/internal/Platform/WebAssemblyConfigLoader.js.map +0 -1
- package/esm/internal/Platform/WebAssemblyResourceLoader.d.ts +0 -24
- package/esm/internal/Platform/WebAssemblyResourceLoader.js +0 -223
- package/esm/internal/Platform/WebAssemblyResourceLoader.js.map +0 -1
- package/esm/internal/Platform/WebAssemblyStartOptions.d.ts +0 -13
- package/esm/internal/Platform/WebAssemblyStartOptions.js +0 -2
- package/esm/internal/Platform/WebAssemblyStartOptions.js.map +0 -1
- package/esm/internal/Rendering/BrowserRenderer.d.ts +0 -38
- package/esm/internal/Rendering/BrowserRenderer.js +0 -458
- package/esm/internal/Rendering/BrowserRenderer.js.map +0 -1
- package/esm/internal/Rendering/ElementReferenceCapture.d.ts +0 -1
- package/esm/internal/Rendering/ElementReferenceCapture.js +0 -24
- package/esm/internal/Rendering/ElementReferenceCapture.js.map +0 -1
- package/esm/internal/Rendering/EventDelegator.d.ts +0 -20
- package/esm/internal/Rendering/EventDelegator.js +0 -236
- package/esm/internal/Rendering/EventDelegator.js.map +0 -1
- package/esm/internal/Rendering/EventFieldInfo.d.ts +0 -6
- package/esm/internal/Rendering/EventFieldInfo.js +0 -32
- package/esm/internal/Rendering/EventFieldInfo.js.map +0 -1
- package/esm/internal/Rendering/EventForDotNet.d.ts +0 -10
- package/esm/internal/Rendering/EventForDotNet.js +0 -194
- package/esm/internal/Rendering/EventForDotNet.js.map +0 -1
- package/esm/internal/Rendering/LogicalElements.d.ts +0 -19
- package/esm/internal/Rendering/LogicalElements.js +0 -250
- package/esm/internal/Rendering/LogicalElements.js.map +0 -1
- package/esm/internal/Rendering/RenderBatch/BinaryDecoder.d.ts +0 -5
- package/esm/internal/Rendering/RenderBatch/BinaryDecoder.js +0 -34
- package/esm/internal/Rendering/RenderBatch/BinaryDecoder.js.map +0 -1
- package/esm/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.d.ts +0 -18
- package/esm/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.js +0 -190
- package/esm/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.js.map +0 -1
- package/esm/internal/Rendering/RenderBatch/RenderBatch.d.ts +0 -87
- package/esm/internal/Rendering/RenderBatch/RenderBatch.js +0 -26
- package/esm/internal/Rendering/RenderBatch/RenderBatch.js.map +0 -1
- package/esm/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.d.ts +0 -52
- package/esm/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.js +0 -103
- package/esm/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.js.map +0 -1
- package/esm/internal/Rendering/RenderBatch/Utf8Decoder.d.ts +0 -1
- package/esm/internal/Rendering/RenderBatch/Utf8Decoder.js +0 -63
- package/esm/internal/Rendering/RenderBatch/Utf8Decoder.js.map +0 -1
- package/esm/internal/Rendering/Renderer.d.ts +0 -8
- package/esm/internal/Rendering/Renderer.js +0 -69
- package/esm/internal/Rendering/Renderer.js.map +0 -1
- package/esm/internal/Rendering/RendererEventDispatcher.d.ts +0 -4
- package/esm/internal/Rendering/RendererEventDispatcher.js +0 -11
- package/esm/internal/Rendering/RendererEventDispatcher.js.map +0 -1
- package/esm/internal/Services/NavigationManager.d.ts +0 -16
- package/esm/internal/Services/NavigationManager.js +0 -138
- package/esm/internal/Services/NavigationManager.js.map +0 -1
- package/esm/internal/globals.d.ts +0 -1
- package/esm/internal/globals.js +0 -5
- package/esm/internal/globals.js.map +0 -1
- package/esm/internal/index.d.ts +0 -15
- package/esm/internal/index.js +0 -152
- package/esm/internal/index.js.map +0 -1
- package/lib/internal/Environment.d.ts +0 -3
- package/lib/internal/Environment.js +0 -9
- package/lib/internal/Environment.js.map +0 -1
- package/lib/internal/Platform/BootConfig.d.ts +0 -20
- package/lib/internal/Platform/BootConfig.js +0 -13
- package/lib/internal/Platform/BootConfig.js.map +0 -1
- package/lib/internal/Platform/Mono/MonoDebugger.d.ts +0 -3
- package/lib/internal/Platform/Mono/MonoDebugger.js +0 -48
- package/lib/internal/Platform/Mono/MonoDebugger.js.map +0 -1
- package/lib/internal/Platform/Mono/MonoPlatform.d.ts +0 -2
- package/lib/internal/Platform/Mono/MonoPlatform.js +0 -406
- package/lib/internal/Platform/Mono/MonoPlatform.js.map +0 -1
- package/lib/internal/Platform/Mono/TimezoneDataFile.d.ts +0 -1
- package/lib/internal/Platform/Mono/TimezoneDataFile.js +0 -55
- package/lib/internal/Platform/Mono/TimezoneDataFile.js.map +0 -1
- package/lib/internal/Platform/Platform.d.ts +0 -31
- package/lib/internal/Platform/Platform.js +0 -3
- package/lib/internal/Platform/Platform.js.map +0 -1
- package/lib/internal/Platform/Url.d.ts +0 -2
- package/lib/internal/Platform/Url.js +0 -16
- package/lib/internal/Platform/Url.js.map +0 -1
- package/lib/internal/Platform/WebAssemblyConfigLoader.d.ts +0 -4
- package/lib/internal/Platform/WebAssemblyConfigLoader.js +0 -67
- package/lib/internal/Platform/WebAssemblyConfigLoader.js.map +0 -1
- package/lib/internal/Platform/WebAssemblyResourceLoader.d.ts +0 -24
- package/lib/internal/Platform/WebAssemblyResourceLoader.js +0 -226
- package/lib/internal/Platform/WebAssemblyResourceLoader.js.map +0 -1
- package/lib/internal/Platform/WebAssemblyStartOptions.d.ts +0 -13
- package/lib/internal/Platform/WebAssemblyStartOptions.js +0 -3
- package/lib/internal/Platform/WebAssemblyStartOptions.js.map +0 -1
- package/lib/internal/Rendering/BrowserRenderer.d.ts +0 -38
- package/lib/internal/Rendering/BrowserRenderer.js +0 -461
- package/lib/internal/Rendering/BrowserRenderer.js.map +0 -1
- package/lib/internal/Rendering/ElementReferenceCapture.d.ts +0 -1
- package/lib/internal/Rendering/ElementReferenceCapture.js +0 -28
- package/lib/internal/Rendering/ElementReferenceCapture.js.map +0 -1
- package/lib/internal/Rendering/EventDelegator.d.ts +0 -20
- package/lib/internal/Rendering/EventDelegator.js +0 -239
- package/lib/internal/Rendering/EventDelegator.js.map +0 -1
- package/lib/internal/Rendering/EventFieldInfo.d.ts +0 -6
- package/lib/internal/Rendering/EventFieldInfo.js +0 -35
- package/lib/internal/Rendering/EventFieldInfo.js.map +0 -1
- package/lib/internal/Rendering/EventForDotNet.d.ts +0 -10
- package/lib/internal/Rendering/EventForDotNet.js +0 -197
- package/lib/internal/Rendering/EventForDotNet.js.map +0 -1
- package/lib/internal/Rendering/LogicalElements.d.ts +0 -19
- package/lib/internal/Rendering/LogicalElements.js +0 -265
- package/lib/internal/Rendering/LogicalElements.js.map +0 -1
- package/lib/internal/Rendering/RenderBatch/BinaryDecoder.d.ts +0 -5
- package/lib/internal/Rendering/RenderBatch/BinaryDecoder.js +0 -42
- package/lib/internal/Rendering/RenderBatch/BinaryDecoder.js.map +0 -1
- package/lib/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.d.ts +0 -18
- package/lib/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.js +0 -193
- package/lib/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.js.map +0 -1
- package/lib/internal/Rendering/RenderBatch/RenderBatch.d.ts +0 -87
- package/lib/internal/Rendering/RenderBatch/RenderBatch.js +0 -29
- package/lib/internal/Rendering/RenderBatch/RenderBatch.js.map +0 -1
- package/lib/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.d.ts +0 -52
- package/lib/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.js +0 -106
- package/lib/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.js.map +0 -1
- package/lib/internal/Rendering/RenderBatch/Utf8Decoder.d.ts +0 -1
- package/lib/internal/Rendering/RenderBatch/Utf8Decoder.js +0 -66
- package/lib/internal/Rendering/RenderBatch/Utf8Decoder.js.map +0 -1
- package/lib/internal/Rendering/Renderer.d.ts +0 -8
- package/lib/internal/Rendering/Renderer.js +0 -76
- package/lib/internal/Rendering/Renderer.js.map +0 -1
- package/lib/internal/Rendering/RendererEventDispatcher.d.ts +0 -4
- package/lib/internal/Rendering/RendererEventDispatcher.js +0 -16
- package/lib/internal/Rendering/RendererEventDispatcher.js.map +0 -1
- package/lib/internal/Services/NavigationManager.d.ts +0 -16
- package/lib/internal/Services/NavigationManager.js +0 -144
- package/lib/internal/Services/NavigationManager.js.map +0 -1
- package/lib/internal/globals.d.ts +0 -1
- package/lib/internal/globals.js +0 -7
- package/lib/internal/globals.js.map +0 -1
- package/lib/internal/index.d.ts +0 -15
- package/lib/internal/index.js +0 -161
- package/lib/internal/index.js.map +0 -1
- package/src/internal/Environment.ts +0 -11
- package/src/internal/Platform/BootConfig.ts +0 -21
- package/src/internal/Platform/Mono/MonoDebugger.ts +0 -48
- package/src/internal/Platform/Mono/MonoPlatform.ts +0 -494
- package/src/internal/Platform/Mono/MonoTypes.d.ts +0 -27
- package/src/internal/Platform/Mono/TimezoneDataFile.ts +0 -46
- package/src/internal/Platform/Platform.ts +0 -40
- package/src/internal/Platform/Url.ts +0 -11
- package/src/internal/Platform/WebAssemblyConfigLoader.ts +0 -34
- package/src/internal/Platform/WebAssemblyResourceLoader.ts +0 -234
- package/src/internal/Platform/WebAssemblyStartOptions.ts +0 -22
- package/src/internal/Rendering/BrowserRenderer.ts +0 -616
- package/src/internal/Rendering/ElementReferenceCapture.ts +0 -27
- package/src/internal/Rendering/EventDelegator.ts +0 -293
- package/src/internal/Rendering/EventFieldInfo.ts +0 -31
- package/src/internal/Rendering/EventForDotNet.ts +0 -370
- package/src/internal/Rendering/LogicalElements.ts +0 -289
- package/src/internal/Rendering/RenderBatch/BinaryDecoder.ts +0 -43
- package/src/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.ts +0 -244
- package/src/internal/Rendering/RenderBatch/RenderBatch.ts +0 -100
- package/src/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.ts +0 -137
- package/src/internal/Rendering/RenderBatch/Utf8Decoder.ts +0 -66
- package/src/internal/Rendering/Renderer.ts +0 -98
- package/src/internal/Rendering/RendererEventDispatcher.ts +0 -20
- package/src/internal/Services/NavigationManager.ts +0 -157
- package/src/internal/globals.ts +0 -5
- package/src/internal/index.ts +0 -170
package/esm/types.d.ts
CHANGED
|
@@ -1,4 +1,60 @@
|
|
|
1
|
-
import type { ForeignComponent } from 'piral-core';
|
|
1
|
+
import type { ForeignComponent, PiletApi } from 'piral-core';
|
|
2
|
+
export type BlazorRootConfig = [
|
|
3
|
+
root: HTMLDivElement,
|
|
4
|
+
capabilities: Array<string>,
|
|
5
|
+
applyChanges: (pilet: PiletApi) => void
|
|
6
|
+
];
|
|
7
|
+
export interface BlazorDependencyLoader {
|
|
8
|
+
(config: BlazorRootConfig): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export type WebAssemblyBootResourceType = 'assembly' | 'pdb' | 'dotnetjs' | 'dotnetwasm' | 'globalization' | 'manifest';
|
|
11
|
+
export interface WebAssemblyStartOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Overrides the built-in boot resource loading mechanism so that boot resources can be fetched
|
|
14
|
+
* from a custom source, such as an external CDN.
|
|
15
|
+
* @param type The type of the resource to be loaded.
|
|
16
|
+
* @param name The name of the resource to be loaded.
|
|
17
|
+
* @param defaultUri The URI from which the framework would fetch the resource by default. The URI may be relative or absolute.
|
|
18
|
+
* @param integrity The integrity string representing the expected content in the response.
|
|
19
|
+
* @returns A URI string or a Response promise to override the loading process, or null/undefined to allow the default loading behavior.
|
|
20
|
+
*/
|
|
21
|
+
loadBootResource?(type: WebAssemblyBootResourceType, name: string, defaultUri: string, integrity: string): string | Promise<Response> | null | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Override built-in environment setting on start.
|
|
24
|
+
*/
|
|
25
|
+
environment?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Gets the application culture. This is a name specified in the BCP 47 format. See https://tools.ietf.org/html/bcp47
|
|
28
|
+
*/
|
|
29
|
+
applicationCulture?: string;
|
|
30
|
+
}
|
|
31
|
+
declare global {
|
|
32
|
+
interface Window {
|
|
33
|
+
Blazor: {
|
|
34
|
+
start(options?: Partial<WebAssemblyStartOptions>): Promise<void>;
|
|
35
|
+
emitPiralEvent(type: string, args: any): void;
|
|
36
|
+
emitRenderEvent(source: HTMLElement, name: string, params: any, sourceRef: any, fallbackComponent: string | null): void;
|
|
37
|
+
emitNavigateEvent(target: Element, path: string, replace?: boolean, state?: any): void;
|
|
38
|
+
_internal: {
|
|
39
|
+
navigationManager: any;
|
|
40
|
+
applyHotReload: any;
|
|
41
|
+
NavigationLock: any;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
DotNet: any;
|
|
45
|
+
$blazorLoader: Promise<BlazorRootConfig>;
|
|
46
|
+
$blazorDependencyPrios: Array<{
|
|
47
|
+
prio: number;
|
|
48
|
+
load(): Promise<void>;
|
|
49
|
+
}>;
|
|
50
|
+
$blazorDependencies: Array<{
|
|
51
|
+
name: string;
|
|
52
|
+
url: string;
|
|
53
|
+
count: number;
|
|
54
|
+
promise: Promise<void>;
|
|
55
|
+
}>;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
2
58
|
declare module 'piral-core/lib/types/custom' {
|
|
3
59
|
interface PiletCustomApi extends PiletBlazorApi {
|
|
4
60
|
}
|
|
@@ -6,6 +62,24 @@ declare module 'piral-core/lib/types/custom' {
|
|
|
6
62
|
blazor(component: BlazorComponent): ForeignComponent<TProps>;
|
|
7
63
|
}
|
|
8
64
|
}
|
|
65
|
+
export declare const enum BlazorLogLevel {
|
|
66
|
+
trace = 0,
|
|
67
|
+
debug = 1,
|
|
68
|
+
info = 2,
|
|
69
|
+
warn = 3,
|
|
70
|
+
error = 4,
|
|
71
|
+
critical = 5,
|
|
72
|
+
none = 6
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Additional options for the Blazor component
|
|
76
|
+
*/
|
|
77
|
+
export interface BlazorOptions {
|
|
78
|
+
/**
|
|
79
|
+
* The root path where resources are located.
|
|
80
|
+
*/
|
|
81
|
+
resourcePathRoot?: string;
|
|
82
|
+
}
|
|
9
83
|
export interface BlazorComponent {
|
|
10
84
|
/**
|
|
11
85
|
* The name of the Blazor module to render.
|
|
@@ -19,26 +93,45 @@ export interface BlazorComponent {
|
|
|
19
93
|
* An optional dependency that needs to load before
|
|
20
94
|
* the component can be properly displayed.
|
|
21
95
|
*/
|
|
22
|
-
dependency?:
|
|
96
|
+
dependency?: BlazorDependencyLoader;
|
|
23
97
|
/**
|
|
24
98
|
* The type of the Blazor component.
|
|
25
99
|
*/
|
|
26
100
|
type: 'blazor';
|
|
101
|
+
/**
|
|
102
|
+
* Additional options for the Blazor component.
|
|
103
|
+
*/
|
|
104
|
+
options?: BlazorOptions;
|
|
27
105
|
}
|
|
28
106
|
/**
|
|
29
107
|
* Defines the provided set of Blazor Pilet API extensions.
|
|
30
108
|
*/
|
|
31
109
|
export interface PiletBlazorApi {
|
|
32
110
|
/**
|
|
33
|
-
* Defines the additional libraries to Blazor via
|
|
111
|
+
* Defines the additional libraries (and their symbols) to Blazor via
|
|
112
|
+
* their URLs.
|
|
113
|
+
*
|
|
34
114
|
* @param referenceUrls The URLs pointing to the different DLLs to include.
|
|
115
|
+
* @param satellites The URLs of the potential satellite DLLs to include.
|
|
116
|
+
* @param prio The loading priority of the DLLs. Higher numbers will always be loaded before lower numbers.
|
|
35
117
|
*/
|
|
36
|
-
defineBlazorReferences(referenceUrls: Array<string
|
|
118
|
+
defineBlazorReferences(referenceUrls: Array<string>, satellites?: Record<string, Array<string>>, prio?: number): void;
|
|
37
119
|
/**
|
|
38
120
|
* Wraps a Blazor module for use in Piral.
|
|
121
|
+
*
|
|
39
122
|
* @param moduleName The name of the exposed Blazor component.
|
|
40
123
|
* @param args The optional props to use as arguments for the Blazor component.
|
|
41
124
|
* @returns The Piral Blazor component.
|
|
42
125
|
*/
|
|
43
126
|
fromBlazor(moduleName: string, args?: Record<string, any>): BlazorComponent;
|
|
127
|
+
/**
|
|
128
|
+
* Defines the additional options to be shared by all Blazor components.
|
|
129
|
+
*
|
|
130
|
+
* @param options The options for the Blazor components.
|
|
131
|
+
*/
|
|
132
|
+
defineBlazorOptions(options: BlazorOptions): void;
|
|
133
|
+
/**
|
|
134
|
+
* Releases all defined blazor references from the current pilet.
|
|
135
|
+
*/
|
|
136
|
+
releaseBlazorReferences(): void;
|
|
44
137
|
}
|
package/infra.codegen
CHANGED
|
@@ -1,84 +1,69 @@
|
|
|
1
|
-
const axios = require('axios');
|
|
2
|
-
const yauzl = require('yauzl');
|
|
3
1
|
const fs = require('fs');
|
|
4
|
-
const
|
|
2
|
+
const { join, basename, dirname, resolve } = require('path');
|
|
5
3
|
|
|
6
|
-
|
|
4
|
+
function copyFileSync(source, target) {
|
|
5
|
+
let targetFile = target;
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
reject(err);
|
|
13
|
-
} else {
|
|
14
|
-
zip.on('entry', (entry) => {
|
|
15
|
-
const file = entry.fileName;
|
|
16
|
-
const dir = path.dirname(file);
|
|
7
|
+
// If target is a directory, a new file with the same name will be created
|
|
8
|
+
if (fs.existsSync(target) && fs.lstatSync(target).isDirectory()) {
|
|
9
|
+
targetFile = join(target, basename(source));
|
|
10
|
+
}
|
|
17
11
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
} else {
|
|
33
|
-
zip.readEntry();
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
zip.on('end', resolve);
|
|
37
|
-
zip.readEntry();
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
});
|
|
12
|
+
fs.writeFileSync(targetFile, fs.readFileSync(source));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function copyFolderRecursiveSync(source, target) {
|
|
16
|
+
// Check if folder needs to be created or integrated
|
|
17
|
+
const targetFolder = join(target, basename(source));
|
|
18
|
+
|
|
19
|
+
if (!fs.existsSync(targetFolder)) {
|
|
20
|
+
fs.mkdirSync(targetFolder);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
copyContentRecursiveSync(source, targetFolder);
|
|
41
24
|
}
|
|
42
25
|
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
26
|
+
function copyContentRecursiveSync(source, target) {
|
|
27
|
+
// Copy
|
|
28
|
+
if (fs.lstatSync(source).isDirectory()) {
|
|
29
|
+
const files = fs.readdirSync(source);
|
|
30
|
+
|
|
31
|
+
files.forEach((file) => {
|
|
32
|
+
const curSource = join(source, file);
|
|
33
|
+
|
|
34
|
+
if (fs.lstatSync(curSource).isDirectory()) {
|
|
35
|
+
copyFolderRecursiveSync(curSource, target);
|
|
36
|
+
} else {
|
|
37
|
+
copyFileSync(curSource, target);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
51
41
|
}
|
|
52
42
|
|
|
53
43
|
module.exports = function () {
|
|
54
|
-
const version = process.env.PIRAL_BLAZOR_VERSION || '';
|
|
55
|
-
const localFile = process.env.PIRAL_BLAZOR_LOCAL_NUPKG;
|
|
56
44
|
const outDir = this.options.outDir;
|
|
57
|
-
const frameworkDir = path.resolve(outDir, '_framework');
|
|
58
|
-
const binDir = path.resolve(frameworkDir, '_bin');
|
|
59
|
-
const wasmDir = path.resolve(frameworkDir, 'wasm');
|
|
60
|
-
const blazorBootFile = path.resolve(frameworkDir, 'blazor.boot.json');
|
|
61
45
|
|
|
62
46
|
!fs.existsSync(outDir) && fs.mkdirSync(outDir, { recursive: true });
|
|
63
|
-
!fs.existsSync(frameworkDir) && fs.mkdirSync(frameworkDir);
|
|
64
|
-
!fs.existsSync(binDir) && fs.mkdirSync(binDir);
|
|
65
|
-
!fs.existsSync(wasmDir) && fs.mkdirSync(wasmDir);
|
|
66
|
-
|
|
67
|
-
if (localFile) {
|
|
68
|
-
if (!fs.existsSync(localFile)) {
|
|
69
|
-
throw new Error(
|
|
70
|
-
`The file provided via env. variable "PIRAL_BLAZOR_LOCAL_NUPKG" cannot be found: "${localFile}".`,
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
47
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
48
|
+
try {
|
|
49
|
+
const blazorPackagePath = require.resolve('blazor/package.json');
|
|
50
|
+
const releaseType = process.env.NODE_ENV === 'production' ? 'release' : 'debug';
|
|
51
|
+
const { blazorConfig = {} } = require(blazorPackagePath);
|
|
52
|
+
const blazorBaseDir = resolve(dirname(blazorPackagePath), releaseType);
|
|
53
|
+
const wwwRootDir = resolve(blazorBaseDir, 'wwwroot');
|
|
54
|
+
const noMutation = blazorConfig.noMutation || false;
|
|
55
|
+
const satellites = blazorConfig.satellites || [];
|
|
56
|
+
const url = blazorConfig.url || '_framework/blazor.webassembly.js';
|
|
57
|
+
const bootConfig = {
|
|
58
|
+
url,
|
|
59
|
+
satellites,
|
|
60
|
+
noMutation,
|
|
61
|
+
};
|
|
77
62
|
|
|
78
|
-
|
|
63
|
+
copyContentRecursiveSync(wwwRootDir, outDir);
|
|
79
64
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
65
|
+
return `export default (${JSON.stringify(bootConfig)});`;
|
|
66
|
+
} catch (err) {
|
|
67
|
+
throw new Error(`The npm package "blazor" was not found. Make sure to install it via "npm i blazor": ${err}`);
|
|
68
|
+
}
|
|
84
69
|
};
|
package/lib/converter.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { BaseComponentProps, ForeignComponent } from 'piral-core';
|
|
2
|
+
import { BlazorDependencyLoader, BlazorLogLevel, BlazorOptions, BlazorRootConfig, WebAssemblyStartOptions } from './types';
|
|
3
|
+
export interface LanguageOptions {
|
|
4
|
+
current: string | undefined;
|
|
5
|
+
onChange(inform: (language: string) => void): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function createConverter(lazy: boolean, opts?: WebAssemblyStartOptions, language?: LanguageOptions, logLevel?: BlazorLogLevel): {
|
|
8
|
+
<TProps extends BaseComponentProps>(moduleName: string, dependency: BlazorDependencyLoader, args: Record<string, any>, options?: BlazorOptions): ForeignComponent<TProps>;
|
|
9
|
+
loader: Promise<BlazorRootConfig>;
|
|
10
|
+
lazy: boolean;
|
|
7
11
|
};
|
package/lib/converter.js
CHANGED
|
@@ -1,58 +1,174 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createConverter = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const events_1 = require("./events");
|
|
6
|
+
const interop_1 = require("./interop");
|
|
7
|
+
const infra_codegen_1 = require("../infra.codegen");
|
|
8
|
+
const noop = () => { };
|
|
9
|
+
const mediaRules = [
|
|
10
|
+
{ attribute: 'src', selector: 'img, embed, video > source, video > track, audio > source' },
|
|
11
|
+
{ attribute: 'srcset', selector: 'picture > source' },
|
|
12
|
+
];
|
|
13
|
+
function prefixMediaSources(component, prefix) {
|
|
14
|
+
const prefixAttributeValue = (el, attr) => el.setAttribute(attr, prefix + el.getAttribute(attr));
|
|
15
|
+
for (const { attribute, selector } of mediaRules) {
|
|
16
|
+
Array.from(component.querySelectorAll(selector))
|
|
17
|
+
.filter((el) => el.hasAttribute(attribute) && !el.getAttribute(attribute).match(/^https?:/))
|
|
18
|
+
.forEach((el) => prefixAttributeValue(el, attribute));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function project(component, destination, options) {
|
|
22
|
+
if ((options === null || options === void 0 ? void 0 : options.resourcePathRoot) && !infra_codegen_1.default.noMutation) {
|
|
23
|
+
prefixMediaSources(component, options.resourcePathRoot);
|
|
24
|
+
}
|
|
25
|
+
destination.appendChild(component);
|
|
26
|
+
}
|
|
27
|
+
function makeUrl(href) {
|
|
28
|
+
const origin = document.location.origin;
|
|
29
|
+
if (!href.startsWith(origin)) {
|
|
30
|
+
return `${origin}${href}`;
|
|
31
|
+
}
|
|
32
|
+
return href;
|
|
33
|
+
}
|
|
34
|
+
function createConverter(lazy, opts, language, logLevel) {
|
|
35
|
+
const bootLoader = (0, interop_1.createBootLoader)(infra_codegen_1.default.url, infra_codegen_1.default.satellites);
|
|
36
|
+
const boot = (opts) => bootLoader(opts).then((res) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const [_, capabilities] = res;
|
|
38
|
+
if (capabilities.includes('logging')) {
|
|
39
|
+
if (typeof logLevel === 'number') {
|
|
40
|
+
yield (0, interop_1.setLogLevel)(logLevel);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (language && capabilities.includes('language')) {
|
|
44
|
+
if (typeof language.current === 'string') {
|
|
45
|
+
yield (0, interop_1.setLanguage)(language.current);
|
|
46
|
+
}
|
|
47
|
+
if (capabilities.includes('events')) {
|
|
48
|
+
const eventDispatcher = document.body.dispatchEvent;
|
|
49
|
+
// listen to all events for forwarding them
|
|
50
|
+
document.body.dispatchEvent = function (ev) {
|
|
51
|
+
if (ev.type.startsWith('piral-')) {
|
|
52
|
+
const type = ev.type.replace('piral-', '');
|
|
53
|
+
const args = ev.detail.arg;
|
|
54
|
+
(0, interop_1.processEvent)(type, args);
|
|
55
|
+
}
|
|
56
|
+
return eventDispatcher.call(this, ev);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (typeof language.onChange === 'function') {
|
|
60
|
+
language.onChange(interop_1.setLanguage);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
window.dispatchEvent(new CustomEvent('loaded-blazor-core'));
|
|
64
|
+
return res;
|
|
65
|
+
}));
|
|
66
|
+
let loader = !lazy && boot(opts);
|
|
67
|
+
let listener = undefined;
|
|
68
|
+
const enqueueChange = (locals, update) => {
|
|
69
|
+
if (typeof update !== 'function') {
|
|
70
|
+
// nothing to do in this case
|
|
71
|
+
}
|
|
72
|
+
else if (locals.state === 'mounted') {
|
|
73
|
+
loader.then(update);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
locals.next = update;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const convert = (moduleName, dependency, args, options) => ({
|
|
80
|
+
mount(el, data, ctx, locals) {
|
|
81
|
+
const props = Object.assign(Object.assign({}, args), data);
|
|
82
|
+
const { piral } = data;
|
|
83
|
+
const nav = ctx.navigation;
|
|
84
|
+
el.setAttribute('data-blazor-pilet-root', 'true');
|
|
85
|
+
(0, events_1.addGlobalEventListeners)(el);
|
|
86
|
+
if (listener === undefined) {
|
|
87
|
+
listener = nav.listen(({ location, action }) => {
|
|
88
|
+
// POP is already handled by .NET
|
|
89
|
+
if (action !== 'POP') {
|
|
90
|
+
const url = makeUrl(location.href);
|
|
91
|
+
(0, interop_1.callNotifyLocationChanged)(url, action === 'REPLACE', location.state);
|
|
33
92
|
}
|
|
34
|
-
})
|
|
35
|
-
.catch(function (err) { return console.error(err); });
|
|
36
|
-
dispose = internal_1.attachEvents(el, function (ev) { return data.piral.renderHtmlExtension(ev.detail.target, ev.detail.props); }, function (ev) {
|
|
37
|
-
return ev.detail.replace
|
|
38
|
-
? ctx.router.history.replace(ev.detail.to, ev.detail.store)
|
|
39
|
-
: ctx.router.history.push(ev.detail.to, ev.detail.state);
|
|
40
93
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
94
|
+
}
|
|
95
|
+
locals.state = 'fresh';
|
|
96
|
+
locals.next = noop;
|
|
97
|
+
locals.dispose = (0, events_1.attachEvents)(el, (ev) => {
|
|
98
|
+
ev.stopPropagation();
|
|
99
|
+
const { target, props } = ev.detail;
|
|
100
|
+
piral.renderHtmlExtension(target, props);
|
|
101
|
+
}, (ev) => {
|
|
102
|
+
ev.stopPropagation();
|
|
103
|
+
const { to, state, replace } = ev.detail;
|
|
104
|
+
replace ? nav.replace(to, state) : nav.push(to, state);
|
|
105
|
+
}, (ev) => {
|
|
106
|
+
ev.stopPropagation();
|
|
107
|
+
const { type, args } = ev.detail;
|
|
108
|
+
piral.emit(type, args);
|
|
109
|
+
});
|
|
110
|
+
function mountClassic(config) {
|
|
111
|
+
return (0, interop_1.activate)(moduleName, props).then((refId) => {
|
|
112
|
+
const [root] = config;
|
|
113
|
+
const node = root.querySelector(`#${refId} > div`);
|
|
114
|
+
locals.unmount = () => {
|
|
115
|
+
var _a;
|
|
116
|
+
(_a = root.querySelector(`#${refId}`)) === null || _a === void 0 ? void 0 : _a.appendChild(node);
|
|
117
|
+
(0, interop_1.deactivate)(moduleName, refId);
|
|
118
|
+
el.innerHTML = '';
|
|
119
|
+
};
|
|
120
|
+
locals.update = (props) => {
|
|
121
|
+
(0, interop_1.reactivate)(moduleName, refId, props);
|
|
122
|
+
};
|
|
123
|
+
project(node, el, options);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function mountModern(_) {
|
|
127
|
+
return (0, interop_1.createElement)(moduleName, props).then((refId) => {
|
|
128
|
+
const child = document.createElement('piral-blazor-component');
|
|
129
|
+
child.setAttribute('rid', refId);
|
|
130
|
+
el.appendChild(child);
|
|
131
|
+
locals.unmount = () => {
|
|
132
|
+
(0, interop_1.destroyElement)(refId);
|
|
133
|
+
child.remove();
|
|
134
|
+
el.innerHTML = '';
|
|
135
|
+
};
|
|
136
|
+
locals.update = (props) => {
|
|
137
|
+
(0, interop_1.updateElement)(refId, props);
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
(loader || (convert.loader = loader = boot(opts)))
|
|
142
|
+
.then((config) => dependency(config).then(() => {
|
|
143
|
+
if (locals.state === 'fresh') {
|
|
144
|
+
const [_, capabilities, applyChanges] = config;
|
|
145
|
+
const fn = capabilities.includes('custom-element') ? mountModern : mountClassic;
|
|
146
|
+
applyChanges(piral);
|
|
147
|
+
return fn(config).then(() => {
|
|
148
|
+
locals.state = 'mounted';
|
|
149
|
+
locals.next(config);
|
|
150
|
+
locals.next = noop;
|
|
151
|
+
});
|
|
49
152
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
153
|
+
}))
|
|
154
|
+
.catch((err) => console.error(err));
|
|
155
|
+
},
|
|
156
|
+
update(el, data, ctx, locals) {
|
|
157
|
+
enqueueChange(locals, () => {
|
|
158
|
+
var _a;
|
|
159
|
+
(_a = locals.update) === null || _a === void 0 ? void 0 : _a.call(locals, Object.assign(Object.assign({}, args), data));
|
|
160
|
+
});
|
|
161
|
+
},
|
|
162
|
+
unmount(el, locals) {
|
|
163
|
+
(0, events_1.removeGlobalEventListeners)(el);
|
|
164
|
+
el.removeAttribute('data-blazor-pilet-root');
|
|
165
|
+
locals.dispose();
|
|
166
|
+
enqueueChange(locals, locals.unmount);
|
|
167
|
+
locals.state = 'removed';
|
|
168
|
+
},
|
|
169
|
+
});
|
|
55
170
|
convert.loader = loader;
|
|
171
|
+
convert.lazy = lazy;
|
|
56
172
|
return convert;
|
|
57
173
|
}
|
|
58
174
|
exports.createConverter = createConverter;
|
package/lib/converter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;;AACA,
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;;AACA,qCAA6F;AAC7F,uCAYmB;AAQnB,oDAA0C;AAE1C,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAEtB,MAAM,UAAU,GAAG;IACjB,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,2DAA2D,EAAE;IAC3F,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,EAAE;CACtD,CAAC;AAEF,SAAS,kBAAkB,CAAC,SAAkB,EAAE,MAAc;IAC5D,MAAM,oBAAoB,GAAG,CAAC,EAAW,EAAE,IAAY,EAAE,EAAE,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,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O,CAAC,CAAC;YACtC,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC;QAC3B,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;IACxB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IACpB,OAAO,OAAO,CAAC;AACjB,CAAC;AA/KD,0CA+KC"}
|
package/lib/create.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PiralPlugin } from 'piral-core';
|
|
2
|
-
import type { PiletBlazorApi } from './types';
|
|
2
|
+
import type { BlazorLogLevel, PiletBlazorApi, WebAssemblyStartOptions } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Available configuration options for the Blazor plugin.
|
|
5
5
|
*/
|
|
@@ -9,6 +9,26 @@ export interface BlazorConfig {
|
|
|
9
9
|
* @default true
|
|
10
10
|
*/
|
|
11
11
|
lazy?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Determines the used log level, if any. Otherwise, will use
|
|
14
|
+
* the default log level (info).
|
|
15
|
+
*/
|
|
16
|
+
logLevel?: BlazorLogLevel;
|
|
17
|
+
/**
|
|
18
|
+
* Determines the initial language to use, if any.
|
|
19
|
+
* Otherwise, falls back to Blazor's default language.
|
|
20
|
+
*/
|
|
21
|
+
initialLanguage?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Installs a function to handle language change. By default,
|
|
24
|
+
* this will hook on to the `select-language` event from Piral.
|
|
25
|
+
* @param inform The callback to use for passing in a new locale.
|
|
26
|
+
*/
|
|
27
|
+
onLanguageChange?: ((inform: (language: string) => void) => void) | false;
|
|
28
|
+
/**
|
|
29
|
+
* Determines the start options to use for booting Blazor.
|
|
30
|
+
*/
|
|
31
|
+
options?: WebAssemblyStartOptions;
|
|
12
32
|
}
|
|
13
33
|
/**
|
|
14
34
|
* Creates new Pilet API extensions for integration of Blazor.
|
package/lib/create.js
CHANGED
|
@@ -1,30 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createBlazorApi = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const converter_1 = require("./converter");
|
|
5
|
+
const dependencies_1 = require("./dependencies");
|
|
6
|
+
function createDefaultHandler(context) {
|
|
7
|
+
return (inform) => {
|
|
8
|
+
context.on('select-language', (ev) => {
|
|
9
|
+
inform(ev.currentLanguage);
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
}
|
|
6
13
|
/**
|
|
7
14
|
* Creates new Pilet API extensions for integration of Blazor.
|
|
8
15
|
*/
|
|
9
|
-
function createBlazorApi(config) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
function createBlazorApi(config = {}) {
|
|
17
|
+
return (context) => {
|
|
18
|
+
const { lazy = true, initialLanguage, onLanguageChange = createDefaultHandler(context), logLevel } = config;
|
|
19
|
+
const convert = (0, converter_1.createConverter)(lazy, config.options, {
|
|
20
|
+
current: initialLanguage,
|
|
21
|
+
onChange: onLanguageChange || (() => { }),
|
|
22
|
+
}, logLevel);
|
|
23
|
+
context.converters.blazor = ({ moduleName, args, dependency, options }) => convert(moduleName, dependency, args, options);
|
|
24
|
+
return (_, meta) => {
|
|
25
|
+
const loader = (0, dependencies_1.createDependencyLoader)(convert);
|
|
26
|
+
let options;
|
|
20
27
|
return {
|
|
21
|
-
defineBlazorReferences
|
|
22
|
-
|
|
28
|
+
defineBlazorReferences(references, satellites, prio) {
|
|
29
|
+
return loader.defineBlazorReferences(references, meta, satellites, prio);
|
|
30
|
+
},
|
|
31
|
+
defineBlazorOptions(blazorOptions) {
|
|
32
|
+
options = blazorOptions;
|
|
33
|
+
},
|
|
34
|
+
releaseBlazorReferences: loader.releaseBlazorReferences,
|
|
35
|
+
fromBlazor(moduleName, args) {
|
|
23
36
|
return {
|
|
24
37
|
type: 'blazor',
|
|
25
38
|
dependency: loader.getDependency(),
|
|
26
|
-
moduleName
|
|
27
|
-
args
|
|
39
|
+
moduleName,
|
|
40
|
+
args,
|
|
41
|
+
options,
|
|
28
42
|
};
|
|
29
43
|
},
|
|
30
44
|
};
|