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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 - 2021 smapiot
3
+ Copyright (c) 2019 - 2023 smapiot
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- [![Piral Logo](https://github.com/smapiot/piral/raw/master/docs/assets/logo.png)](https://piral.io)
1
+ [![Piral Logo](https://github.com/smapiot/piral/raw/main/docs/assets/logo.png)](https://piral.io)
2
2
 
3
- # [Piral Blazor](https://piral.io) · [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/smapiot/piral/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/piral-blazor.svg?style=flat)](https://www.npmjs.com/package/piral-blazor) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://jestjs.io) [![Gitter Chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/piral-io/community)
3
+ # [Piral Blazor](https://piral.io) · [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/smapiot/piral/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/piral-blazor.svg?style=flat)](https://www.npmjs.com/package/piral-blazor) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://jestjs.io) [![Gitter Chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/piral-io/community)
4
4
 
5
- This is a plugin that has a peer dependency to `piral-core` and `blazor`. What `piral-blazor` brings to the table is a set of Pilet API extensions that can be used with `piral` or `piral-core`.
5
+ This is a plugin that has a peer dependency to `blazor`. What `piral-blazor` brings to the table is a set of Pilet API extensions that can be used with `piral` or `piral-core`.
6
6
 
7
7
  The set includes a Blazor (WASM) loader and converter for any component registration, as well as a `fromBlazor` shortcut together with some Blazor component coming in the `Piral.Blazor.Utils` NuGet package.
8
8
 
@@ -67,8 +67,8 @@ Blazor with Piral works from two sides. We have the app shell's side and the sid
67
67
  The diagram has the following pieces:
68
68
 
69
69
  1. Your app shell using `piral`, which needs to reference the `piral-blazor` plugin. Effectively, this will use the `blazor` package at build-time to include the Blazor libraries. Additionally, it uses `Piral.Blazor.Core` to be able to reference the defined Blazor components.
70
- 2. The TypeScript file in your Blazor pilets. That file will export the `setup` function to define which Blazor components to register / use in your app shell.
71
- 3. The Blazor code in your Blazor pilets using the shared library `Piral.Blazor.Utils` for some convenience functions. This code will define all the Blazor components that can be registered / used in the pilet.
70
+ 2. The TypeScript file in your Blazor pilets. That file will export the `setup` function to define which Blazor components to register/use in your app shell.
71
+ 3. The Blazor code in your Blazor pilets using the shared library `Piral.Blazor.Utils` for some convenience functions. This code will define all the Blazor components that can be registered/used in the pilet.
72
72
 
73
73
  Naturally, you can add other dependencies to your Blazor pilet, too. These can be other npm packages for extending the JS part. Usually, however, you will add more NuGet packages to enhance your Blazor code.
74
74
 
@@ -82,7 +82,7 @@ The following functions are brought to the Pilet API.
82
82
 
83
83
  Adds the URLs to additional DLLs that need to be referenced for obtaining the Blazor components. At best this uses `require.resolve` to get the URL from the bundler.
84
84
 
85
- When you use the `blazorpilet` template you don't need to fill / use this. It is automatically used and filled with generated code. Only touch this one if you know what you are doing.
85
+ When you use the `blazorpilet` template you don't need to fill/use this. It is automatically used and filled with generated code. Only touch this one if you know what you are doing.
86
86
 
87
87
  ### `fromBlazor()`
88
88
 
@@ -120,7 +120,7 @@ Alternatively, if `piral-blazor` has not been added to the Piral instance you ca
120
120
 
121
121
  ```ts
122
122
  import { PiletApi } from '<name-of-piral-instance>';
123
- import { defineBlazorReferences, fromBlazor } from 'piral-blazor';
123
+ import { defineBlazorReferences, fromBlazor } from 'piral-blazor/convert';
124
124
 
125
125
  export function setup(piral: PiletApi) {
126
126
  defineBlazorReferences([
@@ -133,7 +133,7 @@ export function setup(piral: PiletApi) {
133
133
 
134
134
  In this case, you'll also have to install the `blazor` package. `piral-blazor` will use this under the hood to access the Blazor libraries.
135
135
 
136
- To maximize compatibility, the major and minor version of the `blazor` package should correspond to the major and minor version of .NET Blazor you want to use (e.g. `blazor@3.2.x` will resolve to the .NET Blazor `3.2` release train). It should be noted that the patch level is not aligned. If a specific patch level is desired, consult the `blazor` package documentation.
136
+ To maximize compatibility, the major and minor version of the `blazor` package should correspond to the major and minor version of .NET Blazor you want to use (e.g., `blazor@3.2.x` will resolve to the .NET Blazor `3.2` release train). It should be noted that the patch level is not aligned. If a specific patch level is desired, consult the `blazor` package documentation.
137
137
 
138
138
  :::
139
139
 
@@ -156,10 +156,52 @@ const instance = createInstance({
156
156
  ```
157
157
  `piral-blazor` will use `blazor` under the hood to access the Blazor libraries.
158
158
 
159
- To maximize compatibility, the major and minor version of the `blazor` package should correspond to the major and minor version of .NET Blazor you want to use (e.g. `blazor@3.2.x` will resolve to the .NET Blazor `3.2` release train). It should be noted that the patch level is not aligned. If a specific patch level is desired, consult the `blazor` package documentation.
159
+ To maximize compatibility, the major and minor version of the `blazor` package should correspond to the major and minor version of .NET Blazor you want to use (e.g., `blazor@3.2.x` will resolve to the .NET Blazor `3.2` release train). It should be noted that the patch level is not aligned. If a specific patch level is desired, consult the `blazor` package documentation.
160
+
161
+ For setting up localization you can supply options such as `initialLanguage` and `onLanguageChange` to the `createBlazorApi` call. While the former is used to set the initial language, the latter can be used to change the language later on. By default, `onLanguageChange` will be configured to listen to the `select-language` event emitted from Piral. This event is emitted (among others) by `piral-translate`, i.e., if you use this plugin it will just work.
162
+
163
+ Otherwise, you can either emit the event yourself (transporting an object with `currentLanguage` set to the desired language), or use `onLanguageChange` to wire it to whatever event source / emitter you'd like.
164
+
165
+ Ultimately, you can also call the `SetLanguage` in Piral.Blazor.Core from JavaScript like this:
166
+
167
+ ```js
168
+ window.DotNet.invokeMethodAsync('Piral.Blazor.Core', 'SetLanguage', language);
169
+ ```
170
+
171
+ Furthermore, it is possible to configure the (initial) log level via the `logLevel` option:
172
+
173
+ ```ts
174
+ const instance = createInstance({
175
+ // important part
176
+ plugins: [createBlazorApi({
177
+ logLevel: 1, // everything except trace
178
+ })],
179
+ // ...
180
+ });
181
+ ```
182
+
183
+ The levels range from 0 (incl. trace) to 6 (nothing will be logged).
160
184
 
161
185
  :::
162
186
 
187
+ ## Events
188
+
189
+ The `piral-blazor` integration emits some events at the global object (`window`):
190
+
191
+ - `loading-blazor-core` when the loading of (core) Blazor resources starts
192
+ - `loaded-blazor-core` when the loading of (core) Blazor resources ends
193
+ - `loading-blazor-pilet` when the loading of a Blazor pilet / its resources starts (`detail` contains the pilet's metadata)
194
+ - `loaded-blazor-pilet` when the loading of a Blazor pilet / its resources ends (`detail` contains the pilet's metadata)
195
+
196
+ You can receive these events using, e.g.:
197
+
198
+ ```js
199
+ window.addEventListener('loaded-blazor-pilet', (ev) => {
200
+ // your code here - could use:
201
+ // ev.detail.name --> name of the pilet
202
+ });
203
+ ```
204
+
163
205
  ## License
164
206
 
165
207
  Piral is released using the MIT license. For more information see the [license file](./LICENSE).
package/convert.d.ts CHANGED
@@ -1,11 +1,16 @@
1
- import type { HtmlComponent } from 'piral-core';
2
- declare const convert: {
3
- <TProps extends import("piral-core").BaseComponentProps>(moduleName: string, dependency: () => Promise<void>, args: Record<string, any>): import("piral-core").ForeignComponent<TProps>;
4
- loader: Promise<unknown>;
5
- };
1
+ import type { BlazorOptions } from './esm/types';
2
+ export interface HtmlComponent<TProps> {
3
+ component: {
4
+ mount(element: HTMLElement, props: TProps, ctx: any, locals: any): void;
5
+ update?(element: HTMLElement, props: TProps, ctx: any, locals: any): void;
6
+ unmount?(element: HTMLElement, locals: any): void;
7
+ };
8
+ type: 'html';
9
+ }
6
10
  export interface BlazorConverter {
7
- (...params: Parameters<typeof convert>): HtmlComponent<any>;
11
+ (moduleName: string, args?: Record<string, any>): HtmlComponent<any>;
8
12
  }
13
+ export declare function defineBlazorOptions(options: BlazorOptions): void;
9
14
  export declare const fromBlazor: BlazorConverter;
10
- export declare const defineBlazorReferences: (references: any) => void;
11
- export {};
15
+ export declare const defineBlazorReferences: (references: string[], meta?: PiletMetadata, satellites?: {}, prio?: number) => void;
16
+ export declare const releaseBlazorReferences: () => Promise<void>;
package/convert.js CHANGED
@@ -1,12 +1,17 @@
1
- "use strict";
2
- exports.__esModule = true;
3
- exports.defineBlazorReferences = exports.fromBlazor = void 0;
4
- var converter_1 = require("./lib/converter");
5
- var dependencies_1 = require("./lib/dependencies");
6
- var convert = converter_1.createConverter();
7
- var loader = dependencies_1.createDependencyLoader(convert);
8
- exports.fromBlazor = function (moduleName, dependency, args) { return ({
9
- type: 'html',
10
- component: convert(moduleName, dependency, args)
11
- }); };
12
- exports.defineBlazorReferences = loader.defineBlazorReferences;
1
+ import { createConverter } from './esm/converter';
2
+ import { createDependencyLoader } from './esm/dependencies';
3
+ var convert = createConverter(true);
4
+ var loader = createDependencyLoader(convert);
5
+ var blazorOptions = undefined;
6
+ export function defineBlazorOptions(options) {
7
+ blazorOptions = options;
8
+ }
9
+ export var fromBlazor = function (moduleName, args) {
10
+ if (args === void 0) { args = {}; }
11
+ return ({
12
+ type: 'html',
13
+ component: convert(moduleName, loader.getDependency(), args, blazorOptions),
14
+ });
15
+ };
16
+ export var defineBlazorReferences = loader.defineBlazorReferences;
17
+ export var releaseBlazorReferences = loader.releaseBlazorReferences;
@@ -1,5 +1,11 @@
1
- import type { ForeignComponent, BaseComponentProps } from 'piral-core';
2
- export declare function createConverter(lazy?: boolean): {
3
- <TProps extends BaseComponentProps>(moduleName: string, dependency: () => Promise<void>, args: Record<string, any>): ForeignComponent<TProps>;
4
- loader: Promise<unknown>;
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;
5
11
  };
package/esm/converter.js CHANGED
@@ -1,57 +1,171 @@
1
- import { __assign } from "tslib";
2
- import { initialize, activate, deactivate, attachEvents, addGlobalEventListeners, removeGlobalEventListeners, } from './interop';
3
- export function createConverter(lazy) {
4
- if (lazy === void 0) { lazy = true; }
5
- var bootConfig = require('../infra.codegen');
6
- var boot = function () { return initialize(bootConfig); };
7
- var root = document.body.appendChild(document.createElement('div'));
8
- var loader = !lazy && boot();
9
- root.style.display = 'none';
10
- root.id = 'blazor-root';
11
- var convert = function (moduleName, dependency, args) {
12
- var id;
13
- var referenceId;
14
- var node;
15
- var dispose = function () { };
16
- var state;
17
- return {
18
- mount: function (el, data, ctx) {
19
- var props = __assign(__assign({}, args), data);
20
- el.setAttribute('data-blazor-pilet-root', 'true');
21
- addGlobalEventListeners(el);
22
- (loader || (loader = boot()))
23
- .then(dependency)
24
- .then(function () { return activate(moduleName, props); })
25
- .then(function (refId) {
26
- if (state === 'fresh') {
27
- id = moduleName + "-" + refId;
28
- node = el.appendChild(root.querySelector("#" + id + " > div"));
29
- state = 'mounted';
30
- referenceId = refId;
1
+ import { __awaiter } from "tslib";
2
+ import { addGlobalEventListeners, attachEvents, removeGlobalEventListeners } from './events';
3
+ import { activate, deactivate, createBootLoader, reactivate, callNotifyLocationChanged, setLanguage, createElement, destroyElement, updateElement, setLogLevel, processEvent, } from './interop';
4
+ import bootConfig from '../infra.codegen';
5
+ const noop = () => { };
6
+ const mediaRules = [
7
+ { attribute: 'src', selector: 'img, embed, video > source, video > track, audio > source' },
8
+ { attribute: 'srcset', selector: 'picture > source' },
9
+ ];
10
+ function prefixMediaSources(component, prefix) {
11
+ const prefixAttributeValue = (el, attr) => el.setAttribute(attr, prefix + el.getAttribute(attr));
12
+ for (const { attribute, selector } of mediaRules) {
13
+ Array.from(component.querySelectorAll(selector))
14
+ .filter((el) => el.hasAttribute(attribute) && !el.getAttribute(attribute).match(/^https?:/))
15
+ .forEach((el) => prefixAttributeValue(el, attribute));
16
+ }
17
+ }
18
+ function project(component, destination, options) {
19
+ if ((options === null || options === void 0 ? void 0 : options.resourcePathRoot) && !bootConfig.noMutation) {
20
+ prefixMediaSources(component, options.resourcePathRoot);
21
+ }
22
+ destination.appendChild(component);
23
+ }
24
+ function makeUrl(href) {
25
+ const origin = document.location.origin;
26
+ if (!href.startsWith(origin)) {
27
+ return `${origin}${href}`;
28
+ }
29
+ return href;
30
+ }
31
+ export function createConverter(lazy, opts, language, logLevel) {
32
+ const bootLoader = createBootLoader(bootConfig.url, bootConfig.satellites);
33
+ const boot = (opts) => bootLoader(opts).then((res) => __awaiter(this, void 0, void 0, function* () {
34
+ const [_, capabilities] = res;
35
+ if (capabilities.includes('logging')) {
36
+ if (typeof logLevel === 'number') {
37
+ yield setLogLevel(logLevel);
38
+ }
39
+ }
40
+ if (language && capabilities.includes('language')) {
41
+ if (typeof language.current === 'string') {
42
+ yield setLanguage(language.current);
43
+ }
44
+ if (capabilities.includes('events')) {
45
+ const eventDispatcher = document.body.dispatchEvent;
46
+ // listen to all events for forwarding them
47
+ document.body.dispatchEvent = function (ev) {
48
+ if (ev.type.startsWith('piral-')) {
49
+ const type = ev.type.replace('piral-', '');
50
+ const args = ev.detail.arg;
51
+ processEvent(type, args);
52
+ }
53
+ return eventDispatcher.call(this, ev);
54
+ };
55
+ }
56
+ if (typeof language.onChange === 'function') {
57
+ language.onChange(setLanguage);
58
+ }
59
+ }
60
+ window.dispatchEvent(new CustomEvent('loaded-blazor-core'));
61
+ return res;
62
+ }));
63
+ let loader = !lazy && boot(opts);
64
+ let listener = undefined;
65
+ const enqueueChange = (locals, update) => {
66
+ if (typeof update !== 'function') {
67
+ // nothing to do in this case
68
+ }
69
+ else if (locals.state === 'mounted') {
70
+ loader.then(update);
71
+ }
72
+ else {
73
+ locals.next = update;
74
+ }
75
+ };
76
+ const convert = (moduleName, dependency, args, options) => ({
77
+ mount(el, data, ctx, locals) {
78
+ const props = Object.assign(Object.assign({}, args), data);
79
+ const { piral } = data;
80
+ const nav = ctx.navigation;
81
+ el.setAttribute('data-blazor-pilet-root', 'true');
82
+ addGlobalEventListeners(el);
83
+ if (listener === undefined) {
84
+ listener = nav.listen(({ location, action }) => {
85
+ // POP is already handled by .NET
86
+ if (action !== 'POP') {
87
+ const url = makeUrl(location.href);
88
+ callNotifyLocationChanged(url, action === 'REPLACE', location.state);
31
89
  }
32
- })
33
- .catch(function (err) { return console.error(err); });
34
- dispose = attachEvents(el, function (ev) { return data.piral.renderHtmlExtension(ev.detail.target, ev.detail.props); }, function (ev) {
35
- return ev.detail.replace
36
- ? ctx.router.history.replace(ev.detail.to, ev.detail.store)
37
- : ctx.router.history.push(ev.detail.to, ev.detail.state);
38
90
  });
39
- state = 'fresh';
40
- },
41
- unmount: function (el) {
42
- removeGlobalEventListeners(el);
43
- el.removeAttribute('data-blazor-pilet-root');
44
- dispose();
45
- if (state === 'mounted') {
46
- root.querySelector("#" + id).appendChild(node);
47
- deactivate(moduleName, referenceId);
91
+ }
92
+ locals.state = 'fresh';
93
+ locals.next = noop;
94
+ locals.dispose = attachEvents(el, (ev) => {
95
+ ev.stopPropagation();
96
+ const { target, props } = ev.detail;
97
+ piral.renderHtmlExtension(target, props);
98
+ }, (ev) => {
99
+ ev.stopPropagation();
100
+ const { to, state, replace } = ev.detail;
101
+ replace ? nav.replace(to, state) : nav.push(to, state);
102
+ }, (ev) => {
103
+ ev.stopPropagation();
104
+ const { type, args } = ev.detail;
105
+ piral.emit(type, args);
106
+ });
107
+ function mountClassic(config) {
108
+ return activate(moduleName, props).then((refId) => {
109
+ const [root] = config;
110
+ const node = root.querySelector(`#${refId} > div`);
111
+ locals.unmount = () => {
112
+ var _a;
113
+ (_a = root.querySelector(`#${refId}`)) === null || _a === void 0 ? void 0 : _a.appendChild(node);
114
+ deactivate(moduleName, refId);
115
+ el.innerHTML = '';
116
+ };
117
+ locals.update = (props) => {
118
+ reactivate(moduleName, refId, props);
119
+ };
120
+ project(node, el, options);
121
+ });
122
+ }
123
+ function mountModern(_) {
124
+ return createElement(moduleName, props).then((refId) => {
125
+ const child = document.createElement('piral-blazor-component');
126
+ child.setAttribute('rid', refId);
127
+ el.appendChild(child);
128
+ locals.unmount = () => {
129
+ destroyElement(refId);
130
+ child.remove();
131
+ el.innerHTML = '';
132
+ };
133
+ locals.update = (props) => {
134
+ updateElement(refId, props);
135
+ };
136
+ });
137
+ }
138
+ (loader || (convert.loader = loader = boot(opts)))
139
+ .then((config) => dependency(config).then(() => {
140
+ if (locals.state === 'fresh') {
141
+ const [_, capabilities, applyChanges] = config;
142
+ const fn = capabilities.includes('custom-element') ? mountModern : mountClassic;
143
+ applyChanges(piral);
144
+ return fn(config).then(() => {
145
+ locals.state = 'mounted';
146
+ locals.next(config);
147
+ locals.next = noop;
148
+ });
48
149
  }
49
- el.innerHTML = '';
50
- state = 'removed';
51
- },
52
- };
53
- };
150
+ }))
151
+ .catch((err) => console.error(err));
152
+ },
153
+ update(el, data, ctx, locals) {
154
+ enqueueChange(locals, () => {
155
+ var _a;
156
+ (_a = locals.update) === null || _a === void 0 ? void 0 : _a.call(locals, Object.assign(Object.assign({}, args), data));
157
+ });
158
+ },
159
+ unmount(el, locals) {
160
+ removeGlobalEventListeners(el);
161
+ el.removeAttribute('data-blazor-pilet-root');
162
+ locals.dispose();
163
+ enqueueChange(locals, locals.unmount);
164
+ locals.state = 'removed';
165
+ },
166
+ });
54
167
  convert.loader = loader;
168
+ convert.lazy = lazy;
55
169
  return convert;
56
170
  }
57
171
  //# sourceMappingURL=converter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"converter.js","sourceRoot":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AC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;oBAChF,YAAY,CAAC,KAAK,CAAC,CAAC;oBAEpB,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;wBAC1B,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC;wBACzB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;wBACpB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;oBACrB,CAAC,CAAC,CAAC;iBACJ;YACH,CAAC,CAAC,CACH;iBACA,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QACxC,CAAC;QACD,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,MAAoB;YACxC,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE;;gBACzB,MAAA,MAAM,CAAC,MAAM,uFAAQ,IAAI,GAAK,IAAI,EAAG,CAAC;YACxC,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,CAAC,EAAE,EAAE,MAAoB;YAC9B,0BAA0B,CAAC,EAAE,CAAC,CAAC;YAC/B,EAAE,CAAC,eAAe,CAAC,wBAAwB,CAAC,CAAC;YAC7C,MAAM,CAAC,OAAO,EAAE,CAAC;YACjB,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,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"}
package/esm/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/esm/create.js CHANGED
@@ -1,27 +1,41 @@
1
1
  import { createConverter } from './converter';
2
2
  import { createDependencyLoader } from './dependencies';
3
+ function createDefaultHandler(context) {
4
+ return (inform) => {
5
+ context.on('select-language', (ev) => {
6
+ inform(ev.currentLanguage);
7
+ });
8
+ };
9
+ }
3
10
  /**
4
11
  * Creates new Pilet API extensions for integration of Blazor.
5
12
  */
6
- export function createBlazorApi(config) {
7
- if (config === void 0) { config = {}; }
8
- var lazy = config.lazy;
9
- return function (context) {
10
- var convert = createConverter(lazy);
11
- context.converters.blazor = function (_a) {
12
- var moduleName = _a.moduleName, args = _a.args, dependency = _a.dependency;
13
- return convert(moduleName, dependency, args);
14
- };
15
- return function () {
16
- var loader = createDependencyLoader(convert, lazy);
13
+ export function createBlazorApi(config = {}) {
14
+ return (context) => {
15
+ const { lazy = true, initialLanguage, onLanguageChange = createDefaultHandler(context), logLevel } = config;
16
+ const convert = createConverter(lazy, config.options, {
17
+ current: initialLanguage,
18
+ onChange: onLanguageChange || (() => { }),
19
+ }, logLevel);
20
+ context.converters.blazor = ({ moduleName, args, dependency, options }) => convert(moduleName, dependency, args, options);
21
+ return (_, meta) => {
22
+ const loader = createDependencyLoader(convert);
23
+ let options;
17
24
  return {
18
- defineBlazorReferences: loader.defineBlazorReferences,
19
- fromBlazor: function (moduleName, args) {
25
+ defineBlazorReferences(references, satellites, prio) {
26
+ return loader.defineBlazorReferences(references, meta, satellites, prio);
27
+ },
28
+ defineBlazorOptions(blazorOptions) {
29
+ options = blazorOptions;
30
+ },
31
+ releaseBlazorReferences: loader.releaseBlazorReferences,
32
+ fromBlazor(moduleName, args) {
20
33
  return {
21
34
  type: 'blazor',
22
35
  dependency: loader.getDependency(),
23
- moduleName: moduleName,
24
- args: args,
36
+ moduleName,
37
+ args,
38
+ options,
25
39
  };
26
40
  },
27
41
  };
package/esm/create.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAcxD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAyB;IAAzB,uBAAA,EAAA,WAAyB;IAC/C,IAAA,IAAI,GAAK,MAAM,KAAX,CAAY;IAExB,OAAO,UAAC,OAAO;QACb,IAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACtC,OAAO,CAAC,UAAU,CAAC,MAAM,GAAG,UAAC,EAAgC;gBAA9B,UAAU,gBAAA,EAAE,IAAI,UAAA,EAAE,UAAU,gBAAA;YAAO,OAAA,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC;QAArC,CAAqC,CAAC;QAExG,OAAO;YACL,IAAM,MAAM,GAAG,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAErD,OAAO;gBACL,sBAAsB,EAAE,MAAM,CAAC,sBAAsB;gBACrD,UAAU,YAAC,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;QAEjD,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE;YACjB,MAAM,MAAM,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;YAC/C,IAAI,OAAsB,CAAC;YAE3B,OAAO;gBACL,sBAAsB,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI;oBACjD,OAAO,MAAM,CAAC,sBAAsB,CAAC,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;gBAC3E,CAAC;gBACD,mBAAmB,CAAC,aAA4B;oBAC9C,OAAO,GAAG,aAAa,CAAC;gBAC1B,CAAC;gBACD,uBAAuB,EAAE,MAAM,CAAC,uBAAuB;gBACvD,UAAU,CAAC,UAAU,EAAE,IAAI;oBACzB,OAAO;wBACL,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE,MAAM,CAAC,aAAa,EAAE;wBAClC,UAAU;wBACV,IAAI;wBACJ,OAAO;qBACR,CAAC;gBACJ,CAAC;aACF,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -1,5 +1,8 @@
1
+ import type { PiletMetadata } from 'piral-core';
1
2
  import type { createConverter } from './converter';
2
- export declare function createDependencyLoader(convert: ReturnType<typeof createConverter>, lazy?: boolean): {
3
- getDependency(): () => Promise<any>;
4
- defineBlazorReferences(references: any): void;
3
+ import type { BlazorDependencyLoader } from './types';
4
+ export declare function createDependencyLoader(convert: ReturnType<typeof createConverter>): {
5
+ getDependency(): BlazorDependencyLoader;
6
+ defineBlazorReferences(references: Array<string>, meta?: Partial<PiletMetadata>, satellites?: {}, prio?: number): void;
7
+ releaseBlazorReferences(): Promise<void>;
5
8
  };