piral-blazor
Advanced tools
Comparing version 1.3.0-beta.6010 to 1.3.0-beta.6013
@@ -115,9 +115,9 @@ var _a, _b; | ||
}); | ||
const lazy = convert.lazy && kind !== 'global'; | ||
depWithPrio.load = () => { | ||
if (!result) { | ||
result = convert.loader.then(load); | ||
result = !lazy ? convert.loader.then(load) : Promise.resolve(); | ||
} | ||
return result; | ||
}; | ||
const lazy = convert.lazy && kind !== 'global'; | ||
result = !lazy && convert.loader.then(load); | ||
@@ -124,0 +124,0 @@ dependency = (config) => result || (result = load(config)); |
@@ -0,1 +1,2 @@ | ||
import { __rest } from "tslib"; | ||
import { emitRenderEvent, emitNavigateEvent, emitPiralEvent } from './events'; | ||
@@ -110,2 +111,11 @@ const wasmLib = 'Microsoft.AspNetCore.Components.WebAssembly'; | ||
} | ||
function sanatize(props) { | ||
// children is a complex thing and will (in general) not be serializable | ||
// hence we need to make the JSObjectReference | ||
if ('children' in props && typeof props.children === 'object') { | ||
const { children } = props, rest = __rest(props, ["children"]); | ||
return Object.assign({ children: window.DotNet.createJSObjectReference(children) }, rest); | ||
} | ||
return props; | ||
} | ||
export function processEvent(type, args) { | ||
@@ -118,6 +128,6 @@ return window.DotNet.invokeMethodAsync(coreLib, 'ProcessEvent', type, args); | ||
export function createElement(moduleName, props) { | ||
return window.DotNet.invokeMethodAsync(coreLib, 'CreateElement', moduleName, props); | ||
return window.DotNet.invokeMethodAsync(coreLib, 'CreateElement', moduleName, sanatize(props)); | ||
} | ||
export function updateElement(referenceId, props) { | ||
return window.DotNet.invokeMethodAsync(coreLib, 'UpdateElement', referenceId, props); | ||
return window.DotNet.invokeMethodAsync(coreLib, 'UpdateElement', referenceId, sanatize(props)); | ||
} | ||
@@ -128,6 +138,6 @@ export function destroyElement(referenceId) { | ||
export function activate(moduleName, props) { | ||
return window.DotNet.invokeMethodAsync(coreLib, 'Activate', moduleName, props); | ||
return window.DotNet.invokeMethodAsync(coreLib, 'Activate', moduleName, sanatize(props)); | ||
} | ||
export function reactivate(moduleName, referenceId, props) { | ||
return window.DotNet.invokeMethodAsync(coreLib, 'Reactivate', moduleName, referenceId, props).catch(() => { | ||
return window.DotNet.invokeMethodAsync(coreLib, 'Reactivate', moduleName, referenceId, sanatize(props)).catch(() => { | ||
// Apparently an older version of Piral.Blazor, which does not support this | ||
@@ -134,0 +144,0 @@ // discard this error silently (in the future we may print warnings here) |
@@ -118,9 +118,9 @@ "use strict"; | ||
}); | ||
const lazy = convert.lazy && kind !== 'global'; | ||
depWithPrio.load = () => { | ||
if (!result) { | ||
result = convert.loader.then(load); | ||
result = !lazy ? convert.loader.then(load) : Promise.resolve(); | ||
} | ||
return result; | ||
}; | ||
const lazy = convert.lazy && kind !== 'global'; | ||
result = !lazy && convert.loader.then(load); | ||
@@ -127,0 +127,0 @@ dependency = (config) => result || (result = load(config)); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createBootLoader = exports.initialize = exports.unloadBlazorPilet = exports.loadBlazorPilet = exports.unloadResource = exports.loadResourceWithSymbol = exports.loadResource = exports.getCapabilities = exports.setLanguage = exports.callNotifyLocationChanged = exports.deactivate = exports.reactivate = exports.activate = exports.destroyElement = exports.updateElement = exports.createElement = exports.setLogLevel = exports.processEvent = void 0; | ||
const tslib_1 = require("tslib"); | ||
const events_1 = require("./events"); | ||
@@ -113,2 +114,11 @@ const wasmLib = 'Microsoft.AspNetCore.Components.WebAssembly'; | ||
} | ||
function sanatize(props) { | ||
// children is a complex thing and will (in general) not be serializable | ||
// hence we need to make the JSObjectReference | ||
if ('children' in props && typeof props.children === 'object') { | ||
const { children } = props, rest = tslib_1.__rest(props, ["children"]); | ||
return Object.assign({ children: window.DotNet.createJSObjectReference(children) }, rest); | ||
} | ||
return props; | ||
} | ||
function processEvent(type, args) { | ||
@@ -123,7 +133,7 @@ return window.DotNet.invokeMethodAsync(coreLib, 'ProcessEvent', type, args); | ||
function createElement(moduleName, props) { | ||
return window.DotNet.invokeMethodAsync(coreLib, 'CreateElement', moduleName, props); | ||
return window.DotNet.invokeMethodAsync(coreLib, 'CreateElement', moduleName, sanatize(props)); | ||
} | ||
exports.createElement = createElement; | ||
function updateElement(referenceId, props) { | ||
return window.DotNet.invokeMethodAsync(coreLib, 'UpdateElement', referenceId, props); | ||
return window.DotNet.invokeMethodAsync(coreLib, 'UpdateElement', referenceId, sanatize(props)); | ||
} | ||
@@ -136,7 +146,7 @@ exports.updateElement = updateElement; | ||
function activate(moduleName, props) { | ||
return window.DotNet.invokeMethodAsync(coreLib, 'Activate', moduleName, props); | ||
return window.DotNet.invokeMethodAsync(coreLib, 'Activate', moduleName, sanatize(props)); | ||
} | ||
exports.activate = activate; | ||
function reactivate(moduleName, referenceId, props) { | ||
return window.DotNet.invokeMethodAsync(coreLib, 'Reactivate', moduleName, referenceId, props).catch(() => { | ||
return window.DotNet.invokeMethodAsync(coreLib, 'Reactivate', moduleName, referenceId, sanatize(props)).catch(() => { | ||
// Apparently an older version of Piral.Blazor, which does not support this | ||
@@ -143,0 +153,0 @@ // discard this error silently (in the future we may print warnings here) |
{ | ||
"name": "piral-blazor", | ||
"version": "1.3.0-beta.6010", | ||
"version": "1.3.0-beta.6013", | ||
"description": "Plugin for integrating Blazor components in Piral.", | ||
@@ -70,5 +70,5 @@ "keywords": [ | ||
"devDependencies": { | ||
"piral-core": "1.3.0-beta.6010" | ||
"piral-core": "1.3.0-beta.6013" | ||
}, | ||
"gitHead": "feee5736c1755e88998926678b1c42be5f792956" | ||
"gitHead": "84e22fa0fb3f049883266268c8e1fbfbf2695e36" | ||
} |
@@ -142,5 +142,7 @@ import type { PiletMetadata } from 'piral-core'; | ||
const lazy = convert.lazy && kind !== 'global'; | ||
depWithPrio.load = () => { | ||
if (!result) { | ||
result = convert.loader.then(load); | ||
result = !lazy ? convert.loader.then(load) : Promise.resolve(); | ||
} | ||
@@ -150,3 +152,2 @@ | ||
}; | ||
const lazy = convert.lazy && kind !== 'global'; | ||
result = !lazy && convert.loader.then(load); | ||
@@ -153,0 +154,0 @@ dependency = (config) => result || (result = load(config)); |
@@ -141,2 +141,16 @@ import { PiletApi } from 'piral-core'; | ||
function sanatize(props: any) { | ||
// children is a complex thing and will (in general) not be serializable | ||
// hence we need to make the JSObjectReference | ||
if ('children' in props && typeof props.children === 'object') { | ||
const { children, ...rest } = props; | ||
return { | ||
children: window.DotNet.createJSObjectReference(children), | ||
...rest, | ||
}; | ||
} | ||
return props; | ||
} | ||
export function processEvent(type: string, args: any) { | ||
@@ -151,7 +165,7 @@ return window.DotNet.invokeMethodAsync(coreLib, 'ProcessEvent', type, args); | ||
export function createElement(moduleName: string, props: any): Promise<string> { | ||
return window.DotNet.invokeMethodAsync(coreLib, 'CreateElement', moduleName, props); | ||
return window.DotNet.invokeMethodAsync(coreLib, 'CreateElement', moduleName, sanatize(props)); | ||
} | ||
export function updateElement(referenceId: string, props: any): Promise<string> { | ||
return window.DotNet.invokeMethodAsync(coreLib, 'UpdateElement', referenceId, props); | ||
return window.DotNet.invokeMethodAsync(coreLib, 'UpdateElement', referenceId, sanatize(props)); | ||
} | ||
@@ -164,7 +178,7 @@ | ||
export function activate(moduleName: string, props: any): Promise<string> { | ||
return window.DotNet.invokeMethodAsync(coreLib, 'Activate', moduleName, props); | ||
return window.DotNet.invokeMethodAsync(coreLib, 'Activate', moduleName, sanatize(props)); | ||
} | ||
export function reactivate(moduleName: string, referenceId: string, props: any): Promise<void> { | ||
return window.DotNet.invokeMethodAsync(coreLib, 'Reactivate', moduleName, referenceId, props).catch(() => { | ||
return window.DotNet.invokeMethodAsync(coreLib, 'Reactivate', moduleName, referenceId, sanatize(props)).catch(() => { | ||
// Apparently an older version of Piral.Blazor, which does not support this | ||
@@ -171,0 +185,0 @@ // discard this error silently (in the future we may print warnings here) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
196063
3097