piral-blazor
Advanced tools
Comparing version 1.6.0-beta.7199 to 1.6.0-beta.7201
@@ -1,5 +0,6 @@ | ||
export declare function emitUpdateEvent(source: HTMLElement, name: string, params: any, sourceRef: any, fallbackComponent: string | null): void; | ||
export declare function emitRenderEvent(source: HTMLElement, name: string, params: any, sourceRef: any, fallbackComponent: string | null): void; | ||
export declare const blazorRootId = "blazor-root"; | ||
export declare function emitUpdateEvent(target: HTMLElement, name: string, params: any, sourceRef: any, fallbackComponent: string | null): void; | ||
export declare function emitRenderEvent(target: HTMLElement, name: string, params: any, sourceRef: any, fallbackComponent: string | null): void; | ||
export declare function emitPiralEvent(type: string, args: any): void; | ||
export declare function emitNavigateEvent(source: HTMLElement, to: string, replace?: boolean, state?: any): void; | ||
export declare function emitNavigateEvent(target: HTMLElement, to: string, replace?: boolean, state?: any): void; | ||
export declare function attachLocalEvents(host: HTMLElement, render: (ev: CustomEvent) => void, navigate: (ev: CustomEvent) => void): () => void; |
import { createElement } from 'react'; | ||
import { isInternalNavigation, performInternalNavigation } from './navigation'; | ||
const blazorRootId = 'blazor-root'; | ||
export const blazorRootId = 'blazor-root'; | ||
const eventParents = []; | ||
@@ -98,11 +98,11 @@ const globalEventNames = [ | ||
} | ||
export function emitUpdateEvent(source, name, params, sourceRef, fallbackComponent) { | ||
const target = findTarget(source); | ||
export function emitUpdateEvent(target, name, params, sourceRef, fallbackComponent) { | ||
const container = findTarget(target); | ||
const eventInit = { | ||
detail: getProps(name, params, sourceRef, fallbackComponent), | ||
}; | ||
target.dispatchEvent(new CustomEvent(eventNames.update, eventInit)); | ||
container.dispatchEvent(new CustomEvent(eventNames.update, eventInit)); | ||
} | ||
export function emitRenderEvent(source, name, params, sourceRef, fallbackComponent) { | ||
const target = findTarget(source); | ||
export function emitRenderEvent(target, name, params, sourceRef, fallbackComponent) { | ||
const container = findTarget(target); | ||
const eventInit = { | ||
@@ -121,8 +121,12 @@ bubbles: true, | ||
const delayEmit = () => requestAnimationFrame(() => { | ||
if (!isRooted(target)) { | ||
target.dispatchEvent(new CustomEvent(eventNames.render, eventInit)); | ||
if (!isRooted(container)) { | ||
return container.dispatchEvent(new CustomEvent(eventNames.render, eventInit)); | ||
} | ||
else { | ||
delayEmit(); | ||
const eventParent = eventParents[0]; | ||
const root = document.getElementById(blazorRootId); | ||
// this would be used exclusively by providers | ||
if (eventParent && root.getAttribute('render') === 'modern') { | ||
return eventParent.dispatchEvent(new CustomEvent(eventNames.render, eventInit)); | ||
} | ||
delayEmit(); | ||
}); | ||
@@ -140,4 +144,5 @@ delayEmit(); | ||
} | ||
export function emitNavigateEvent(source, to, replace = false, state) { | ||
findTarget(source).dispatchEvent(new CustomEvent(eventNames.navigate, { | ||
export function emitNavigateEvent(target, to, replace = false, state) { | ||
const container = findTarget(target); | ||
container.dispatchEvent(new CustomEvent(eventNames.navigate, { | ||
bubbles: true, | ||
@@ -144,0 +149,0 @@ detail: { |
@@ -1,2 +0,2 @@ | ||
import { emitRenderEvent, emitUpdateEvent, emitNavigateEvent, emitPiralEvent } from './events'; | ||
import { emitRenderEvent, emitUpdateEvent, emitNavigateEvent, emitPiralEvent, blazorRootId } from './events'; | ||
const wasmLib = 'Microsoft.AspNetCore.Components.WebAssembly'; | ||
@@ -29,3 +29,3 @@ const coreLib = 'Piral.Blazor.Core'; | ||
} | ||
function prepareForStartup() { | ||
async function prepareForStartup() { | ||
const originalApplyHotReload = window.Blazor._internal.applyHotReload; | ||
@@ -45,6 +45,10 @@ const queue = []; | ||
}; | ||
return getCapabilities().then((capabilities) => ({ | ||
const capabilities = await getCapabilities(); | ||
if (capabilities.includes('custom-element')) { | ||
document.getElementById(blazorRootId).setAttribute('render', 'modern'); | ||
} | ||
return { | ||
capabilities, | ||
applyChanges, | ||
})); | ||
}; | ||
} | ||
@@ -54,3 +58,3 @@ function createBlazorStarter(publicPath) { | ||
root.style.display = 'contents'; | ||
root.id = 'blazor-root'; | ||
root.id = blazorRootId; | ||
if (publicPath) { | ||
@@ -57,0 +61,0 @@ const baseElement = document.head.querySelector('base') || createBase(); |
@@ -1,5 +0,6 @@ | ||
export declare function emitUpdateEvent(source: HTMLElement, name: string, params: any, sourceRef: any, fallbackComponent: string | null): void; | ||
export declare function emitRenderEvent(source: HTMLElement, name: string, params: any, sourceRef: any, fallbackComponent: string | null): void; | ||
export declare const blazorRootId = "blazor-root"; | ||
export declare function emitUpdateEvent(target: HTMLElement, name: string, params: any, sourceRef: any, fallbackComponent: string | null): void; | ||
export declare function emitRenderEvent(target: HTMLElement, name: string, params: any, sourceRef: any, fallbackComponent: string | null): void; | ||
export declare function emitPiralEvent(type: string, args: any): void; | ||
export declare function emitNavigateEvent(source: HTMLElement, to: string, replace?: boolean, state?: any): void; | ||
export declare function emitNavigateEvent(target: HTMLElement, to: string, replace?: boolean, state?: any): void; | ||
export declare function attachLocalEvents(host: HTMLElement, render: (ev: CustomEvent) => void, navigate: (ev: CustomEvent) => void): () => void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.attachLocalEvents = exports.emitNavigateEvent = exports.emitPiralEvent = exports.emitRenderEvent = exports.emitUpdateEvent = void 0; | ||
exports.attachLocalEvents = exports.emitNavigateEvent = exports.emitPiralEvent = exports.emitRenderEvent = exports.emitUpdateEvent = exports.blazorRootId = void 0; | ||
const react_1 = require("react"); | ||
const navigation_1 = require("./navigation"); | ||
const blazorRootId = 'blazor-root'; | ||
exports.blazorRootId = 'blazor-root'; | ||
const eventParents = []; | ||
@@ -41,3 +41,3 @@ const globalEventNames = [ | ||
while (parent) { | ||
if (parent.id === blazorRootId) { | ||
if (parent.id === exports.blazorRootId) { | ||
return true; | ||
@@ -67,3 +67,3 @@ } | ||
const eventClone = new event.constructor(event.type, event); | ||
document.getElementById(blazorRootId)?.dispatchEvent(eventClone); | ||
document.getElementById(exports.blazorRootId)?.dispatchEvent(eventClone); | ||
// make sure to only process every event once; even though multiple boundaries might be active | ||
@@ -103,12 +103,12 @@ event.processed = true; | ||
} | ||
function emitUpdateEvent(source, name, params, sourceRef, fallbackComponent) { | ||
const target = findTarget(source); | ||
function emitUpdateEvent(target, name, params, sourceRef, fallbackComponent) { | ||
const container = findTarget(target); | ||
const eventInit = { | ||
detail: getProps(name, params, sourceRef, fallbackComponent), | ||
}; | ||
target.dispatchEvent(new CustomEvent(eventNames.update, eventInit)); | ||
container.dispatchEvent(new CustomEvent(eventNames.update, eventInit)); | ||
} | ||
exports.emitUpdateEvent = emitUpdateEvent; | ||
function emitRenderEvent(source, name, params, sourceRef, fallbackComponent) { | ||
const target = findTarget(source); | ||
function emitRenderEvent(target, name, params, sourceRef, fallbackComponent) { | ||
const container = findTarget(target); | ||
const eventInit = { | ||
@@ -127,8 +127,12 @@ bubbles: true, | ||
const delayEmit = () => requestAnimationFrame(() => { | ||
if (!isRooted(target)) { | ||
target.dispatchEvent(new CustomEvent(eventNames.render, eventInit)); | ||
if (!isRooted(container)) { | ||
return container.dispatchEvent(new CustomEvent(eventNames.render, eventInit)); | ||
} | ||
else { | ||
delayEmit(); | ||
const eventParent = eventParents[0]; | ||
const root = document.getElementById(exports.blazorRootId); | ||
// this would be used exclusively by providers | ||
if (eventParent && root.getAttribute('render') === 'modern') { | ||
return eventParent.dispatchEvent(new CustomEvent(eventNames.render, eventInit)); | ||
} | ||
delayEmit(); | ||
}); | ||
@@ -148,4 +152,5 @@ delayEmit(); | ||
exports.emitPiralEvent = emitPiralEvent; | ||
function emitNavigateEvent(source, to, replace = false, state) { | ||
findTarget(source).dispatchEvent(new CustomEvent(eventNames.navigate, { | ||
function emitNavigateEvent(target, to, replace = false, state) { | ||
const container = findTarget(target); | ||
container.dispatchEvent(new CustomEvent(eventNames.navigate, { | ||
bubbles: true, | ||
@@ -152,0 +157,0 @@ detail: { |
@@ -32,3 +32,3 @@ "use strict"; | ||
} | ||
function prepareForStartup() { | ||
async function prepareForStartup() { | ||
const originalApplyHotReload = window.Blazor._internal.applyHotReload; | ||
@@ -48,6 +48,10 @@ const queue = []; | ||
}; | ||
return getCapabilities().then((capabilities) => ({ | ||
const capabilities = await getCapabilities(); | ||
if (capabilities.includes('custom-element')) { | ||
document.getElementById(events_1.blazorRootId).setAttribute('render', 'modern'); | ||
} | ||
return { | ||
capabilities, | ||
applyChanges, | ||
})); | ||
}; | ||
} | ||
@@ -57,3 +61,3 @@ function createBlazorStarter(publicPath) { | ||
root.style.display = 'contents'; | ||
root.id = 'blazor-root'; | ||
root.id = events_1.blazorRootId; | ||
if (publicPath) { | ||
@@ -60,0 +64,0 @@ const baseElement = document.head.querySelector('base') || createBase(); |
{ | ||
"name": "piral-blazor", | ||
"version": "1.6.0-beta.7199", | ||
"version": "1.6.0-beta.7201", | ||
"description": "Plugin for integrating Blazor components in Piral.", | ||
@@ -70,5 +70,5 @@ "keywords": [ | ||
"devDependencies": { | ||
"piral-core": "1.6.0-beta.7199" | ||
"piral-core": "1.6.0-beta.7201" | ||
}, | ||
"gitHead": "de50a2e3e7bd3478bbc35cfffdc5dd7bdbbb4045" | ||
"gitHead": "225e9b3b4b56b0aaf334b8799b6c0c4275059534" | ||
} |
@@ -5,3 +5,4 @@ import type { ExtensionRegistration } from 'piral-core'; | ||
const blazorRootId = 'blazor-root'; | ||
export const blazorRootId = 'blazor-root'; | ||
const eventParents: Array<HTMLElement> = []; | ||
@@ -115,3 +116,3 @@ | ||
export function emitUpdateEvent( | ||
source: HTMLElement, | ||
target: HTMLElement, | ||
name: string, | ||
@@ -122,3 +123,3 @@ params: any, | ||
) { | ||
const target = findTarget(source); | ||
const container = findTarget(target); | ||
const eventInit = { | ||
@@ -128,7 +129,7 @@ detail: getProps(name, params, sourceRef, fallbackComponent), | ||
target.dispatchEvent(new CustomEvent(eventNames.update, eventInit)); | ||
container.dispatchEvent(new CustomEvent(eventNames.update, eventInit)); | ||
} | ||
export function emitRenderEvent( | ||
source: HTMLElement, | ||
target: HTMLElement, | ||
name: string, | ||
@@ -139,3 +140,3 @@ params: any, | ||
) { | ||
const target = findTarget(source); | ||
const container = findTarget(target); | ||
const eventInit = { | ||
@@ -156,7 +157,15 @@ bubbles: true, | ||
requestAnimationFrame(() => { | ||
if (!isRooted(target)) { | ||
target.dispatchEvent(new CustomEvent(eventNames.render, eventInit)); | ||
} else { | ||
delayEmit(); | ||
if (!isRooted(container)) { | ||
return container.dispatchEvent(new CustomEvent(eventNames.render, eventInit)); | ||
} | ||
const eventParent = eventParents[0]; | ||
const root = document.getElementById(blazorRootId); | ||
// this would be used exclusively by providers | ||
if (eventParent && root.getAttribute('render') === 'modern') { | ||
return eventParent.dispatchEvent(new CustomEvent(eventNames.render, eventInit)); | ||
} | ||
delayEmit(); | ||
}); | ||
@@ -179,4 +188,5 @@ | ||
export function emitNavigateEvent(source: HTMLElement, to: string, replace = false, state?: any) { | ||
findTarget(source).dispatchEvent( | ||
export function emitNavigateEvent(target: HTMLElement, to: string, replace = false, state?: any) { | ||
const container = findTarget(target); | ||
container.dispatchEvent( | ||
new CustomEvent(eventNames.navigate, { | ||
@@ -183,0 +193,0 @@ bubbles: true, |
import { PiletApi } from 'piral-core'; | ||
import { emitRenderEvent, emitUpdateEvent, emitNavigateEvent, emitPiralEvent } from './events'; | ||
import { emitRenderEvent, emitUpdateEvent, emitNavigateEvent, emitPiralEvent, blazorRootId } from './events'; | ||
import type { BlazorLogLevel, BlazorRootConfig, WebAssemblyStartOptions } from './types'; | ||
@@ -39,3 +39,3 @@ | ||
function prepareForStartup() { | ||
async function prepareForStartup() { | ||
const originalApplyHotReload = window.Blazor._internal.applyHotReload; | ||
@@ -60,6 +60,12 @@ const queue = []; | ||
return getCapabilities().then((capabilities) => ({ | ||
const capabilities = await getCapabilities(); | ||
if (capabilities.includes('custom-element')) { | ||
document.getElementById(blazorRootId).setAttribute('render', 'modern'); | ||
} | ||
return { | ||
capabilities, | ||
applyChanges, | ||
})); | ||
}; | ||
} | ||
@@ -71,3 +77,3 @@ | ||
root.style.display = 'contents'; | ||
root.id = 'blazor-root'; | ||
root.id = blazorRootId; | ||
@@ -74,0 +80,0 @@ if (publicPath) { |
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
204481
3257