piral-blazor 1.0.0-pre.2296 → 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.
Files changed (53) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +51 -9
  3. package/convert.d.ts +13 -8
  4. package/convert.js +17 -12
  5. package/esm/converter.d.ts +10 -4
  6. package/esm/converter.js +164 -50
  7. package/esm/converter.js.map +1 -1
  8. package/esm/create.d.ts +21 -1
  9. package/esm/create.js +29 -15
  10. package/esm/create.js.map +1 -1
  11. package/esm/dependencies.d.ts +6 -3
  12. package/esm/dependencies.js +104 -14
  13. package/esm/dependencies.js.map +1 -1
  14. package/esm/events.d.ts +6 -0
  15. package/esm/events.js +145 -0
  16. package/esm/events.js.map +1 -0
  17. package/esm/interop.d.ts +29 -12
  18. package/esm/interop.js +181 -119
  19. package/esm/interop.js.map +1 -1
  20. package/esm/navigation.d.ts +2 -0
  21. package/esm/navigation.js +30 -0
  22. package/esm/navigation.js.map +1 -0
  23. package/esm/types.d.ts +97 -4
  24. package/infra.codegen +32 -23
  25. package/lib/converter.d.ts +10 -4
  26. package/lib/converter.js +164 -50
  27. package/lib/converter.js.map +1 -1
  28. package/lib/create.d.ts +21 -1
  29. package/lib/create.js +31 -17
  30. package/lib/create.js.map +1 -1
  31. package/lib/dependencies.d.ts +6 -3
  32. package/lib/dependencies.js +104 -14
  33. package/lib/dependencies.js.map +1 -1
  34. package/lib/events.d.ts +6 -0
  35. package/lib/events.js +154 -0
  36. package/lib/events.js.map +1 -0
  37. package/lib/index.js +1 -1
  38. package/lib/interop.d.ts +29 -12
  39. package/lib/interop.js +196 -124
  40. package/lib/interop.js.map +1 -1
  41. package/lib/navigation.d.ts +2 -0
  42. package/lib/navigation.js +35 -0
  43. package/lib/navigation.js.map +1 -0
  44. package/lib/types.d.ts +97 -4
  45. package/package.json +26 -7
  46. package/src/converter.ts +233 -63
  47. package/src/create.ts +53 -9
  48. package/src/dependencies.ts +122 -14
  49. package/src/events.ts +174 -0
  50. package/src/interop.ts +228 -117
  51. package/src/navigation.ts +36 -0
  52. package/src/types.ts +115 -4
  53. package/convert.ts +0 -17
package/src/interop.ts CHANGED
@@ -1,162 +1,273 @@
1
- export const eventNames = {
2
- render: 'render-blazor-extension',
3
- navigate: 'navigate-blazor',
4
- };
1
+ import { PiletApi } from 'piral-core';
2
+ import { emitRenderEvent, emitNavigateEvent, emitPiralEvent } from './events';
3
+ import type { BlazorLogLevel, BlazorRootConfig, WebAssemblyStartOptions } from './types';
5
4
 
5
+ const wasmLib = 'Microsoft.AspNetCore.Components.WebAssembly';
6
6
  const coreLib = 'Piral.Blazor.Core';
7
- const eventParents: Array<HTMLElement> = [];
8
- const blazorRootId = 'blazor-root';
9
-
10
- const globalEventNames = [
11
- 'abort',
12
- 'blur',
13
- 'change',
14
- 'error',
15
- 'focus',
16
- 'load',
17
- 'loadend',
18
- 'loadstart',
19
- 'mouseenter',
20
- 'mouseleave',
21
- 'progress',
22
- 'reset',
23
- 'scroll',
24
- 'submit',
25
- 'unload',
26
- 'DOMNodeInsertedIntoDocument',
27
- 'DOMNodeRemovedFromDocument',
28
- 'click',
29
- 'dblclick',
30
- 'mousedown',
31
- 'mousemove',
32
- 'mouseup',
33
- ];
34
-
35
- function dispatchToRoot(event: Event) {
36
- document.getElementById(blazorRootId)?.dispatchEvent(new Event(event.type, event));
37
- }
38
-
39
- function isRooted(target: HTMLElement) {
40
- let parent = target.parentElement;
41
-
42
- while (parent) {
43
- if (parent.id === blazorRootId) {
44
- return true;
7
+
8
+ function isDotNet6OrBelow() {
9
+ return typeof window.Blazor._internal.NavigationLock === 'undefined';
10
+ }
11
+
12
+ function createBase() {
13
+ // Nothing found, we need to guess
14
+ const el = document.createElement('base');
15
+ let baseUrl = el.href;
16
+
17
+ // The main app is served by a script - but we don't know which one
18
+ // hence we just iterate over all the local ones and use the script
19
+ // that is served from the "shortest" route - should work almost
20
+ // always and if not - one can always explicitely set a <base> node
21
+ for (let i = document.scripts.length; i--; ) {
22
+ const s = document.scripts[i];
23
+ const src = s.getAttribute('src');
24
+
25
+ if (src && src.startsWith('/')) {
26
+ const segEnd = src.lastIndexOf('/');
27
+ const newUrl = src.substring(0, segEnd + 1);
28
+
29
+ if (baseUrl.split('/').length > newUrl.split('/').length) {
30
+ baseUrl = newUrl;
31
+ }
45
32
  }
33
+ }
34
+
35
+ el.href = baseUrl;
36
+ return document.head.appendChild(el);
37
+ }
38
+
39
+ function prepareForStartup() {
40
+ const originalApplyHotReload = window.Blazor._internal.applyHotReload;
41
+ const queue = [];
42
+
43
+ const applyChanges = (api: PiletApi) => {
44
+ const pilet = api.meta;
45
+
46
+ if (pilet.config && pilet.config.blazorHotReload) {
47
+ for (const item of queue.splice(0, queue.length)) {
48
+ item();
49
+ }
50
+
51
+ window.Blazor._internal.applyHotReload = originalApplyHotReload;
52
+ }
53
+ };
54
+
55
+ window.Blazor._internal.applyHotReload = function (...args) {
56
+ queue.push(() => originalApplyHotReload.apply(this, args));
57
+ };
46
58
 
47
- parent = parent.parentElement;
59
+ return getCapabilities().then((capabilities) => ({
60
+ capabilities,
61
+ applyChanges,
62
+ }));
63
+ }
64
+
65
+ function createBlazorStarter(publicPath: string): (opts: WebAssemblyStartOptions) => Promise<BlazorRootConfig> {
66
+ const root = document.body.appendChild(document.createElement('div'));
67
+
68
+ root.style.display = 'none';
69
+ root.id = 'blazor-root';
70
+
71
+ if (publicPath) {
72
+ const baseElement = document.head.querySelector('base') || createBase();
73
+ const originalBase = baseElement.href;
74
+ baseElement.href = publicPath;
75
+
76
+ return (opts) => {
77
+ const navManager = window.Blazor._internal.navigationManager;
78
+
79
+ //Overwrite to get NavigationManager in Blazor working, see https://github.com/smapiot/Piral.Blazor/issues/89
80
+ navManager.navigateTo = (
81
+ route: string,
82
+ opts: { forceLoad: boolean; replaceHistoryEntry: boolean; historyEntryState: any },
83
+ ) => {
84
+ if (opts.forceLoad) {
85
+ location.href = route;
86
+ return;
87
+ }
88
+
89
+ if (route.startsWith(location.origin) && '') {
90
+ // normalize "local" absolute URLs
91
+ route = route.substring(location.origin.length);
92
+ } else if (/^https?:\/\//.test(route)) {
93
+ // prevent absolute URLs to be a standard navigation
94
+ location.href = route;
95
+ return;
96
+ }
97
+
98
+ window.Blazor.emitNavigateEvent(undefined, route, opts.replaceHistoryEntry, opts.historyEntryState);
99
+ };
100
+
101
+ navManager.getBaseURI = () => originalBase;
102
+
103
+ return window.Blazor.start(opts)
104
+ .then(prepareForStartup)
105
+ .then(({ capabilities, applyChanges }) => {
106
+ baseElement.href = originalBase;
107
+ return [root, capabilities, applyChanges];
108
+ });
109
+ };
48
110
  }
49
111
 
50
- return false;
112
+ return (opts) =>
113
+ window.Blazor.start(opts)
114
+ .then(prepareForStartup)
115
+ .then(({ capabilities, applyChanges }) => [root, capabilities, applyChanges]);
51
116
  }
52
117
 
53
- function findTarget(target: HTMLElement = document.body) {
54
- if (eventParents.length === 0) {
55
- return target;
56
- } else if (target === document.body) {
57
- return eventParents[0];
58
- } else {
59
- return target;
118
+ function computePath() {
119
+ try {
120
+ throw new Error();
121
+ } catch (t) {
122
+ const e = ('' + t.stack).match(/(https?|file|ftp|chrome-extension|moz-extension):\/\/[^)\n]+/g);
123
+ if (e) {
124
+ return e[0].replace(/^((?:https?|file|ftp|chrome-extension|moz-extension):\/\/.+)\/[^\/]+$/, '$1') + '/';
125
+ }
60
126
  }
127
+
128
+ return '/';
61
129
  }
62
130
 
63
- function emitRenderEvent(source: HTMLElement, name: string) {
64
- const target = findTarget(source);
65
- const eventInit = {
66
- bubbles: true,
67
- detail: {
68
- target,
69
- props: {
70
- name,
71
- },
72
- },
73
- };
74
- const delayEmit = () =>
75
- requestAnimationFrame(() => {
76
- if (!isRooted(target)) {
77
- target.dispatchEvent(new CustomEvent(eventNames.render, eventInit));
78
- } else {
79
- delayEmit();
80
- }
81
- });
82
- delayEmit();
131
+ function addScript(url: string) {
132
+ return new Promise<void>((resolve, reject) => {
133
+ const script = document.createElement('script');
134
+ script.src = url;
135
+ script.onerror = () => reject();
136
+ script.onload = () => resolve();
137
+ document.body.appendChild(script);
138
+ });
83
139
  }
84
140
 
85
- function emitNavigateEvent(source: HTMLElement, to: string, replace = false, state?: any) {
86
- findTarget(source).dispatchEvent(
87
- new CustomEvent(eventNames.navigate, {
88
- bubbles: true,
89
- detail: {
90
- to,
91
- replace,
92
- state,
93
- },
94
- }),
95
- );
141
+ export function processEvent(type: string, args: any) {
142
+ return window.DotNet.invokeMethodAsync(coreLib, 'ProcessEvent', type, args);
96
143
  }
97
144
 
98
- export function addGlobalEventListeners(el: HTMLElement) {
99
- globalEventNames.forEach((eventName) => el.addEventListener(eventName, dispatchToRoot));
145
+ export function setLogLevel(logLevel: BlazorLogLevel) {
146
+ return window.DotNet.invokeMethodAsync(coreLib, 'SetLogLevel', logLevel);
100
147
  }
101
148
 
102
- export function removeGlobalEventListeners(el: HTMLElement) {
103
- globalEventNames.forEach((eventName) => el.removeEventListener(eventName, dispatchToRoot));
149
+ export function createElement(moduleName: string, props: any): Promise<string> {
150
+ return window.DotNet.invokeMethodAsync(coreLib, 'CreateElement', moduleName, props);
104
151
  }
105
152
 
106
- export function activate(moduleName: string, props: any) {
107
- return window['DotNet'].invokeMethodAsync<string>(coreLib, 'Activate', moduleName, props);
153
+ export function updateElement(referenceId: string, props: any): Promise<string> {
154
+ return window.DotNet.invokeMethodAsync(coreLib, 'UpdateElement', referenceId, props);
108
155
  }
109
156
 
110
- export function deactivate(moduleName: string, referenceId: string) {
111
- return window['DotNet'].invokeMethodAsync<string>(coreLib, 'Deactivate', moduleName, referenceId);
157
+ export function destroyElement(referenceId: string): Promise<string> {
158
+ return window.DotNet.invokeMethodAsync(coreLib, 'DestroyElement', referenceId);
112
159
  }
113
160
 
114
- export function addReference(blob: Blob) {
115
- return new Promise((resolve) => {
116
- const reader = new FileReader();
117
- reader.onload = () => {
118
- const data = reader.result.toString().replace(/^data:.+;base64,/, '');
119
- window['DotNet'].invokeMethodAsync(coreLib, 'LoadComponentsFromLibrary', data).then(resolve);
120
- };
121
- reader.readAsDataURL(blob);
161
+ export function activate(moduleName: string, props: any): Promise<string> {
162
+ return window.DotNet.invokeMethodAsync(coreLib, 'Activate', moduleName, props);
163
+ }
164
+
165
+ export function reactivate(moduleName: string, referenceId: string, props: any): Promise<void> {
166
+ return window.DotNet.invokeMethodAsync(coreLib, 'Reactivate', moduleName, referenceId, props).catch(() => {
167
+ // Apparently an older version of Piral.Blazor, which does not support this
168
+ // discard this error silently (in the future we may print warnings here)
122
169
  });
123
170
  }
124
171
 
125
- export function removeReference(name: string) {
126
- return window['DotNet'].invokeMethodAsync(coreLib, 'UnloadComponentsFromLibrary', name);
172
+ export function deactivate(moduleName: string, referenceId: string): Promise<void> {
173
+ return window.DotNet.invokeMethodAsync(coreLib, 'Deactivate', moduleName, referenceId);
127
174
  }
128
175
 
129
- export function attachEvents(
130
- host: HTMLElement,
131
- render: (ev: CustomEvent) => void,
132
- navigate: (ev: CustomEvent) => void,
133
- ) {
134
- eventParents.push(host);
135
- host.addEventListener(eventNames.render, render, false);
136
- host.addEventListener(eventNames.navigate, navigate, false);
137
- return () => {
138
- eventParents.splice(eventParents.indexOf(host), 1);
139
- host.removeEventListener(eventNames.render, render, false);
140
- host.removeEventListener(eventNames.navigate, navigate, false);
141
- };
176
+ export function callNotifyLocationChanged(url: string, replace: boolean, state: any): Promise<void> {
177
+ if (isDotNet6OrBelow()) {
178
+ return window.DotNet.invokeMethodAsync(wasmLib, 'NotifyLocationChanged', url, replace);
179
+ } else {
180
+ if (state !== undefined && typeof state !== 'string') {
181
+ state = JSON.stringify(state);
182
+ }
183
+
184
+ return window.DotNet.invokeMethodAsync(wasmLib, 'NotifyLocationChanged', url, state, replace);
185
+ }
186
+ }
187
+
188
+ export function setLanguage(language: string): Promise<void> {
189
+ return window.DotNet.invokeMethodAsync(coreLib, 'SetLanguage', language);
190
+ }
191
+
192
+ export function getCapabilities(): Promise<Array<string>> {
193
+ return window.DotNet.invokeMethodAsync(coreLib, 'GetCapabilities').catch(() => {
194
+ // Apparently an older version of Piral.Blazor, which does not support this
195
+ // discard this error silently (in the future we may print warnings here)
196
+ return [];
197
+ });
198
+ }
199
+
200
+ export function loadResource(url: string): Promise<void> {
201
+ return window.DotNet.invokeMethodAsync(coreLib, 'LoadComponentsFromLibrary', url);
202
+ }
203
+
204
+ export function loadResourceWithSymbol(dllUrl: string, pdbUrl: string): Promise<void> {
205
+ return window.DotNet.invokeMethodAsync(coreLib, 'LoadComponentsWithSymbolsFromLibrary', dllUrl, pdbUrl);
206
+ }
207
+
208
+ export function unloadResource(url: string): Promise<void> {
209
+ return window.DotNet.invokeMethodAsync(coreLib, 'UnloadComponentsFromLibrary', url);
210
+ }
211
+
212
+ export interface PiletData {
213
+ dllUrl: string;
214
+ pdbUrl?: string;
215
+ name: string;
216
+ version: string;
217
+ config: string;
218
+ baseUrl: string;
219
+ satellites?: Record<string, Array<string>>;
220
+ dependencies: Array<string>;
221
+ }
222
+
223
+ export function loadBlazorPilet(id: string, data: PiletData) {
224
+ return window.DotNet.invokeMethodAsync(coreLib, 'LoadPilet', id, data);
225
+ }
226
+
227
+ export function unloadBlazorPilet(id: string) {
228
+ return window.DotNet.invokeMethodAsync(coreLib, 'UnloadPilet', id);
142
229
  }
143
230
 
144
- export function initialize(scriptUrl: string) {
145
- return new Promise((resolve, reject) => {
231
+ export function initialize(scriptUrl: string, publicPath: string, opts: WebAssemblyStartOptions = {}) {
232
+ if (typeof opts.loadBootResource !== 'function') {
233
+ opts.loadBootResource = (type, name, url) =>
234
+ type === 'dotnetjs' ? url : fetch(url, { method: 'GET', cache: 'no-cache' });
235
+ }
236
+
237
+ return new Promise<BlazorRootConfig>((resolve, reject) => {
238
+ const startBlazor = createBlazorStarter(publicPath);
146
239
  const script = document.createElement('script');
147
240
  script.src = scriptUrl;
148
241
  script.setAttribute('autostart', 'false');
149
242
 
150
243
  script.onerror = () => reject();
151
244
  script.onload = () => {
152
- Object.assign(window['Blazor'], {
245
+ Object.assign(window.Blazor, {
153
246
  emitRenderEvent,
154
247
  emitNavigateEvent,
248
+ emitPiralEvent,
155
249
  });
156
250
 
157
- window['Blazor'].start().then(resolve);
251
+ startBlazor(opts).then(resolve);
158
252
  };
159
253
 
160
254
  document.body.appendChild(script);
161
255
  });
162
256
  }
257
+
258
+ export function createBootLoader(scriptUrl: string, extraScriptUrls: Array<string>) {
259
+ const publicPath = computePath();
260
+
261
+ return (opts?: WebAssemblyStartOptions) => {
262
+ if (typeof window.$blazorLoader === 'undefined') {
263
+ window.dispatchEvent(new CustomEvent('loading-blazor-core'));
264
+
265
+ // we load all satellite scripts before we initialize blazor
266
+ window.$blazorLoader = Promise.all(extraScriptUrls.map(addScript)).then(() =>
267
+ initialize(scriptUrl, publicPath, opts),
268
+ );
269
+ }
270
+
271
+ return window.$blazorLoader;
272
+ };
273
+ }
@@ -0,0 +1,36 @@
1
+ function findClosestAncestor(element: Element | null, tagName: string) {
2
+ // tslint:disable-next-line:no-null-keyword
3
+ return !element ? null : element.tagName === tagName ? element : findClosestAncestor(element.parentElement, tagName);
4
+ }
5
+
6
+ function getAnchorTarget(event: MouseEvent) {
7
+ return findClosestAncestor(event.target as Element | null, 'A') as HTMLAnchorElement | null;
8
+ }
9
+
10
+ function isWithinBaseUriSpace(href: string) {
11
+ const baseURI = document.baseURI;
12
+ const baseUriUntilLastSlash = baseURI.substr(0, baseURI.lastIndexOf('/') + 1);
13
+ return href.startsWith(baseUriUntilLastSlash);
14
+ }
15
+
16
+ function eventHasSpecialKey(event: MouseEvent) {
17
+ return event.ctrlKey || event.shiftKey || event.altKey || event.metaKey;
18
+ }
19
+
20
+ export function isInternalNavigation(event: MouseEvent) {
21
+ const anchorTarget = getAnchorTarget(event);
22
+ return (
23
+ event.type === 'click' &&
24
+ event.button === 0 &&
25
+ !eventHasSpecialKey(event) &&
26
+ anchorTarget?.hasAttribute('href') &&
27
+ isWithinBaseUriSpace(anchorTarget.href)
28
+ );
29
+ }
30
+
31
+ export function performInternalNavigation(event: MouseEvent) {
32
+ const anchorTarget = getAnchorTarget(event);
33
+ event.preventDefault();
34
+ const to = anchorTarget.getAttribute('href');
35
+ window.Blazor.emitNavigateEvent(anchorTarget, to);
36
+ }
package/src/types.ts CHANGED
@@ -1,4 +1,76 @@
1
- import type { ForeignComponent } from 'piral-core';
1
+ import type { ForeignComponent, PiletApi } from 'piral-core';
2
+
3
+ export type BlazorRootConfig = [
4
+ root: HTMLDivElement,
5
+ capabilities: Array<string>,
6
+ applyChanges: (pilet: PiletApi) => void,
7
+ ];
8
+
9
+ export interface BlazorDependencyLoader {
10
+ (config: BlazorRootConfig): Promise<void>;
11
+ }
12
+
13
+ export type WebAssemblyBootResourceType = 'assembly' | 'pdb' | 'dotnetjs' | 'dotnetwasm' | 'globalization' | 'manifest';
14
+
15
+ export interface WebAssemblyStartOptions {
16
+ /**
17
+ * Overrides the built-in boot resource loading mechanism so that boot resources can be fetched
18
+ * from a custom source, such as an external CDN.
19
+ * @param type The type of the resource to be loaded.
20
+ * @param name The name of the resource to be loaded.
21
+ * @param defaultUri The URI from which the framework would fetch the resource by default. The URI may be relative or absolute.
22
+ * @param integrity The integrity string representing the expected content in the response.
23
+ * @returns A URI string or a Response promise to override the loading process, or null/undefined to allow the default loading behavior.
24
+ */
25
+ loadBootResource?(
26
+ type: WebAssemblyBootResourceType,
27
+ name: string,
28
+ defaultUri: string,
29
+ integrity: string,
30
+ ): string | Promise<Response> | null | undefined;
31
+ /**
32
+ * Override built-in environment setting on start.
33
+ */
34
+ environment?: string;
35
+ /**
36
+ * Gets the application culture. This is a name specified in the BCP 47 format. See https://tools.ietf.org/html/bcp47
37
+ */
38
+ applicationCulture?: string;
39
+ }
40
+
41
+ declare global {
42
+ interface Window {
43
+ Blazor: {
44
+ start(options?: Partial<WebAssemblyStartOptions>): Promise<void>;
45
+ emitPiralEvent(type: string, args: any): void;
46
+ emitRenderEvent(
47
+ source: HTMLElement,
48
+ name: string,
49
+ params: any,
50
+ sourceRef: any,
51
+ fallbackComponent: string | null,
52
+ ): void;
53
+ emitNavigateEvent(target: Element, path: string, replace?: boolean, state?: any): void;
54
+ _internal: {
55
+ navigationManager: any;
56
+ applyHotReload: any;
57
+ NavigationLock: any;
58
+ };
59
+ };
60
+ DotNet: any;
61
+ $blazorLoader: Promise<BlazorRootConfig>;
62
+ $blazorDependencyPrios: Array<{
63
+ prio: number;
64
+ load(): Promise<void>;
65
+ }>;
66
+ $blazorDependencies: Array<{
67
+ name: string;
68
+ url: string;
69
+ count: number;
70
+ promise: Promise<void>;
71
+ }>;
72
+ }
73
+ }
2
74
 
3
75
  declare module 'piral-core/lib/types/custom' {
4
76
  interface PiletCustomApi extends PiletBlazorApi {}
@@ -8,6 +80,26 @@ declare module 'piral-core/lib/types/custom' {
8
80
  }
9
81
  }
10
82
 
83
+ export const enum BlazorLogLevel {
84
+ trace = 0,
85
+ debug = 1,
86
+ info = 2,
87
+ warn = 3,
88
+ error = 4,
89
+ critical = 5,
90
+ none = 6,
91
+ }
92
+
93
+ /**
94
+ * Additional options for the Blazor component
95
+ */
96
+ export interface BlazorOptions {
97
+ /**
98
+ * The root path where resources are located.
99
+ */
100
+ resourcePathRoot?: string;
101
+ }
102
+
11
103
  export interface BlazorComponent {
12
104
  /**
13
105
  * The name of the Blazor module to render.
@@ -21,11 +113,15 @@ export interface BlazorComponent {
21
113
  * An optional dependency that needs to load before
22
114
  * the component can be properly displayed.
23
115
  */
24
- dependency?: () => Promise<void>;
116
+ dependency?: BlazorDependencyLoader;
25
117
  /**
26
118
  * The type of the Blazor component.
27
119
  */
28
120
  type: 'blazor';
121
+ /**
122
+ * Additional options for the Blazor component.
123
+ */
124
+ options?: BlazorOptions;
29
125
  }
30
126
 
31
127
  /**
@@ -33,15 +129,30 @@ export interface BlazorComponent {
33
129
  */
34
130
  export interface PiletBlazorApi {
35
131
  /**
36
- * Defines the additional libraries to Blazor via their URLs.
132
+ * Defines the additional libraries (and their symbols) to Blazor via
133
+ * their URLs.
134
+ *
37
135
  * @param referenceUrls The URLs pointing to the different DLLs to include.
136
+ * @param satellites The URLs of the potential satellite DLLs to include.
137
+ * @param prio The loading priority of the DLLs. Higher numbers will always be loaded before lower numbers.
38
138
  */
39
- defineBlazorReferences(referenceUrls: Array<string>): void;
139
+ defineBlazorReferences(referenceUrls: Array<string>, satellites?: Record<string, Array<string>>, prio?: number): void;
40
140
  /**
41
141
  * Wraps a Blazor module for use in Piral.
142
+ *
42
143
  * @param moduleName The name of the exposed Blazor component.
43
144
  * @param args The optional props to use as arguments for the Blazor component.
44
145
  * @returns The Piral Blazor component.
45
146
  */
46
147
  fromBlazor(moduleName: string, args?: Record<string, any>): BlazorComponent;
148
+ /**
149
+ * Defines the additional options to be shared by all Blazor components.
150
+ *
151
+ * @param options The options for the Blazor components.
152
+ */
153
+ defineBlazorOptions(options: BlazorOptions): void;
154
+ /**
155
+ * Releases all defined blazor references from the current pilet.
156
+ */
157
+ releaseBlazorReferences(): void;
47
158
  }
package/convert.ts DELETED
@@ -1,17 +0,0 @@
1
- import type { HtmlComponent } from 'piral-core';
2
- import { createConverter } from './lib/converter';
3
- import { createDependencyLoader } from './lib/dependencies';
4
-
5
- const convert = createConverter();
6
- const loader = createDependencyLoader(convert);
7
-
8
- export interface BlazorConverter {
9
- (...params: Parameters<typeof convert>): HtmlComponent<any>;
10
- }
11
-
12
- export const fromBlazor: BlazorConverter = (moduleName, dependency, args) => ({
13
- type: 'html',
14
- component: convert(moduleName, dependency, args),
15
- });
16
-
17
- export const defineBlazorReferences = loader.defineBlazorReferences;