@rindo/core
Version:
A Compiler for Web Components and Progressive Web Apps
1,386 lines (1,358 loc) • 139 kB
JavaScript
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/testing/platform/index.ts
var platform_exports = {};
__export(platform_exports, {
Build: () => Build,
Env: () => import_app_data22.Env,
Fragment: () => Fragment,
Host: () => Host,
addHostEventListeners: () => addHostEventListeners,
bootstrapLazy: () => bootstrapLazy,
connectedCallback: () => connectedCallback,
consoleDevError: () => consoleDevError,
consoleDevInfo: () => consoleDevInfo,
consoleDevWarn: () => consoleDevWarn,
consoleError: () => consoleError,
createEvent: () => createEvent,
defineCustomElement: () => defineCustomElement,
deleteHostRef: () => deleteHostRef,
disconnectedCallback: () => disconnectedCallback,
doc: () => doc,
flushAll: () => flushAll,
flushLoadModule: () => flushLoadModule,
flushQueue: () => flushQueue,
forceModeUpdate: () => forceModeUpdate,
forceUpdate: () => forceUpdate,
getAssetPath: () => getAssetPath,
getElement: () => getElement,
getHostRef: () => getHostRef,
getMode: () => getMode,
getRenderingRef: () => getRenderingRef,
getValue: () => getValue,
h: () => h,
insertVdomAnnotations: () => insertVdomAnnotations,
isMemberInElement: () => isMemberInElement,
loadModule: () => loadModule,
modeResolutionChain: () => modeResolutionChain,
nextTick: () => nextTick,
parsePropertyValue: () => parsePropertyValue,
plt: () => plt,
postUpdateComponent: () => postUpdateComponent,
proxyComponent: () => proxyComponent,
proxyCustomElement: () => proxyCustomElement,
readTask: () => readTask,
registerComponents: () => registerComponents,
registerHost: () => registerHost,
registerInstance: () => registerInstance,
registerModule: () => registerModule,
renderVdom: () => renderVdom,
resetPlatform: () => resetPlatform,
setAssetPath: () => setAssetPath,
setErrorHandler: () => setErrorHandler,
setMode: () => setMode,
setNonce: () => setNonce,
setPlatformHelpers: () => setPlatformHelpers,
setPlatformOptions: () => setPlatformOptions,
setSupportsShadowDom: () => setSupportsShadowDom,
setValue: () => setValue,
startAutoApplyChanges: () => startAutoApplyChanges,
stopAutoApplyChanges: () => stopAutoApplyChanges,
styles: () => styles,
supportsConstructableStylesheets: () => supportsConstructableStylesheets,
supportsListenerOptions: () => supportsListenerOptions,
supportsShadow: () => supportsShadow,
win: () => win,
writeTask: () => writeTask
});
module.exports = __toCommonJS(platform_exports);
// src/testing/platform/testing-build.ts
var Build = {
isDev: true,
isBrowser: false,
isServer: true,
isTesting: true
};
// src/testing/platform/testing-constants.ts
var styles = /* @__PURE__ */ new Map();
var modeResolutionChain = [];
var cstrs = /* @__PURE__ */ new Map();
var queuedTicks = [];
var queuedWriteTasks = [];
var queuedReadTasks = [];
var moduleLoaded = /* @__PURE__ */ new Map();
var queuedLoadModules = [];
var caughtErrors = [];
var hostRefs = /* @__PURE__ */ new Map();
// src/testing/platform/testing-host-ref.ts
var getHostRef = (elm) => {
return hostRefs.get(elm);
};
var deleteHostRef = (ref) => hostRefs.delete(ref);
var registerInstance = (lazyInstance, hostRef) => {
if (lazyInstance == null || lazyInstance.constructor == null) {
throw new Error(`Invalid component constructor`);
}
if (hostRef == null) {
const Cstr = lazyInstance.constructor;
const tagName = Cstr.COMPILER_META && Cstr.COMPILER_META.tagName ? Cstr.COMPILER_META.tagName : "div";
const elm = document.createElement(tagName);
registerHost(elm, { $flags$: 0, $tagName$: tagName });
hostRef = getHostRef(elm);
}
hostRef.$lazyInstance$ = lazyInstance;
return hostRefs.set(lazyInstance, hostRef);
};
var registerHost = (elm, cmpMeta) => {
const hostRef = {
$flags$: 0,
$hostElement$: elm,
$cmpMeta$: cmpMeta,
$instanceValues$: /* @__PURE__ */ new Map(),
$renderCount$: 0
};
hostRef.$onInstancePromise$ = new Promise((r) => hostRef.$onInstanceResolve$ = r);
hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
elm["s-p"] = [];
elm["s-rc"] = [];
hostRefs.set(elm, hostRef);
};
// src/testing/platform/testing-log.ts
var customError;
var defaultConsoleError = (e) => {
caughtErrors.push(e);
};
var consoleError = (e, el) => (customError || defaultConsoleError)(e, el);
var consoleDevError = (...e) => {
caughtErrors.push(new Error(e.join(", ")));
};
var consoleDevWarn = (...args) => {
const params = args.filter((a) => typeof a === "string" || typeof a === "number" || typeof a === "boolean");
console.warn(...params);
};
var consoleDevInfo = (..._) => {
};
var setErrorHandler = (handler) => customError = handler;
// src/testing/platform/testing-task-queue.ts
function resetTaskQueue() {
queuedTicks.length = 0;
queuedWriteTasks.length = 0;
queuedReadTasks.length = 0;
moduleLoaded.clear();
queuedLoadModules.length = 0;
caughtErrors.length = 0;
}
var nextTick = (cb) => {
queuedTicks.push(cb);
};
function flushTicks() {
return new Promise((resolve, reject) => {
function drain() {
try {
if (queuedTicks.length > 0) {
const writeTasks = queuedTicks.slice();
queuedTicks.length = 0;
let cb;
while (cb = writeTasks.shift()) {
cb(Date.now());
}
}
if (queuedTicks.length > 0) {
process.nextTick(drain);
} else {
resolve();
}
} catch (e) {
reject(`flushTicks: ${e}`);
}
}
process.nextTick(drain);
});
}
function writeTask(cb) {
queuedWriteTasks.push(cb);
}
function readTask(cb) {
queuedReadTasks.push(cb);
}
function flushQueue() {
return new Promise((resolve, reject) => {
async function drain() {
try {
if (queuedReadTasks.length > 0) {
const readTasks = queuedReadTasks.slice();
queuedReadTasks.length = 0;
let cb;
while (cb = readTasks.shift()) {
const result = cb(Date.now());
if (result != null && typeof result.then === "function") {
await result;
}
}
}
if (queuedWriteTasks.length > 0) {
const writeTasks = queuedWriteTasks.slice();
queuedWriteTasks.length = 0;
let cb;
while (cb = writeTasks.shift()) {
const result = cb(Date.now());
if (result != null && typeof result.then === "function") {
await result;
}
}
}
if (queuedReadTasks.length + queuedWriteTasks.length > 0) {
process.nextTick(drain);
} else {
resolve();
}
} catch (e) {
reject(`flushQueue: ${e}`);
}
}
process.nextTick(drain);
});
}
async function flushAll() {
while (queuedTicks.length + queuedLoadModules.length + queuedWriteTasks.length + queuedReadTasks.length > 0) {
await flushTicks();
await flushLoadModule();
await flushQueue();
}
if (caughtErrors.length > 0) {
const err2 = caughtErrors[0];
if (err2 == null) {
throw new Error("Error!");
}
if (typeof err2 === "string") {
throw new Error(err2);
}
throw err2;
}
return new Promise((resolve) => process.nextTick(resolve));
}
function loadModule(cmpMeta, _hostRef, _hmrVersionId) {
return new Promise((resolve) => {
queuedLoadModules.push({
bundleId: cmpMeta.$lazyBundleId$,
resolve: () => resolve(moduleLoaded.get(cmpMeta.$lazyBundleId$))
});
});
}
function flushLoadModule(bundleId) {
return new Promise((resolve, reject) => {
try {
process.nextTick(() => {
if (bundleId != null) {
for (let i2 = 0; i2 < queuedLoadModules.length; i2++) {
if (queuedLoadModules[i2].bundleId === bundleId) {
queuedLoadModules[i2].resolve();
queuedLoadModules.splice(i2, 1);
i2--;
}
}
} else {
let queuedLoadModule;
while (queuedLoadModule = queuedLoadModules.shift()) {
queuedLoadModule.resolve();
}
}
resolve();
});
} catch (e) {
reject(`flushLoadModule: ${e}`);
}
});
}
// src/testing/platform/testing-window.ts
var import_mock_doc = require("../../mock-doc/index.cjs");
var win = (0, import_mock_doc.setupGlobal)(global);
var doc = win.document;
// src/testing/platform/testing-platform.ts
var supportsShadow = true;
var plt = {
$flags$: 0,
$resourcesUrl$: "",
jmp: (h2) => h2(),
raf: (h2) => requestAnimationFrame(h2),
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
ce: (eventName, opts) => new win.CustomEvent(eventName, opts)
};
var setPlatformHelpers = (helpers) => {
Object.assign(plt, helpers);
};
var supportsListenerOptions = true;
var supportsConstructableStylesheets = false;
var setSupportsShadowDom = (supports) => {
supportsShadow = supports;
};
function resetPlatform(defaults = {}) {
if (win && typeof win.close === "function") {
win.close();
}
hostRefs.clear();
styles.clear();
plt.$flags$ = 0;
Object.assign(plt, defaults);
if (plt.$orgLocNodes$ != null) {
plt.$orgLocNodes$.clear();
plt.$orgLocNodes$ = void 0;
}
win.location.href = plt.$resourcesUrl$ = `http://rindojs-testing.web.app/`;
resetTaskQueue();
stopAutoApplyChanges();
cstrs.clear();
}
var isAutoApplyingChanges = false;
var autoApplyTimer = void 0;
function stopAutoApplyChanges() {
isAutoApplyingChanges = false;
if (autoApplyTimer) {
clearTimeout(autoApplyTimer);
autoApplyTimer = void 0;
}
}
async function startAutoApplyChanges() {
isAutoApplyingChanges = true;
flushAll().then(() => {
if (isAutoApplyingChanges) {
autoApplyTimer = setTimeout(() => {
startAutoApplyChanges();
}, 100);
}
});
}
var registerComponents = (Cstrs) => {
Cstrs.filter((Cstr) => Cstr.COMPILER_META).forEach((Cstr) => {
cstrs.set(Cstr.COMPILER_META.tagName, Cstr);
});
};
function registerModule(bundleId, Cstr) {
moduleLoaded.set(bundleId, Cstr);
}
var isMemberInElement = (elm, memberName) => {
if (elm != null) {
if (memberName in elm) {
return true;
}
const nodeName = elm.nodeName;
if (nodeName) {
const cstr = cstrs.get(nodeName.toLowerCase());
if (cstr != null && cstr.COMPILER_META != null && cstr.COMPILER_META.properties != null) {
return cstr.COMPILER_META.properties.some((p) => p.name === memberName);
}
}
}
return false;
};
// src/testing/platform/index.ts
var import_app_data22 = require("@rindo/core/internal/app-data");
// src/runtime/asset-path.ts
var getAssetPath = (path) => {
const assetUrl = new URL(path, plt.$resourcesUrl$);
return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
};
var setAssetPath = (path) => plt.$resourcesUrl$ = path;
// src/runtime/bootstrap-custom-element.ts
var import_app_data19 = require("@rindo/core/internal/app-data");
// src/utils/constants.ts
var SVG_NS = "http://www.w3.org/2000/svg";
var HTML_NS = "http://www.w3.org/1999/xhtml";
// src/utils/helpers.ts
var isDef = (v) => v != null && v !== void 0;
var isComplexType = (o) => {
o = typeof o;
return o === "object" || o === "function";
};
// src/utils/query-nonce-meta-tag-content.ts
function queryNonceMetaTagContent(doc2) {
var _a, _b, _c;
return (_c = (_b = (_a = doc2.head) == null ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) == null ? void 0 : _b.getAttribute("content")) != null ? _c : void 0;
}
// src/utils/result.ts
var result_exports = {};
__export(result_exports, {
err: () => err,
map: () => map,
ok: () => ok,
unwrap: () => unwrap,
unwrapErr: () => unwrapErr
});
var ok = (value) => ({
isOk: true,
isErr: false,
value
});
var err = (value) => ({
isOk: false,
isErr: true,
value
});
function map(result, fn) {
if (result.isOk) {
const val = fn(result.value);
if (val instanceof Promise) {
return val.then((newVal) => ok(newVal));
} else {
return ok(val);
}
}
if (result.isErr) {
const value = result.value;
return err(value);
}
throw "should never get here";
}
var unwrap = (result) => {
if (result.isOk) {
return result.value;
} else {
throw result.value;
}
};
var unwrapErr = (result) => {
if (result.isErr) {
return result.value;
} else {
throw result.value;
}
};
// src/runtime/connected-callback.ts
var import_app_data17 = require("@rindo/core/internal/app-data");
// src/runtime/client-hydrate.ts
var import_app_data8 = require("@rindo/core/internal/app-data");
// src/runtime/dom-extras.ts
var import_app_data6 = require("@rindo/core/internal/app-data");
// src/runtime/runtime-constants.ts
var CONTENT_REF_ID = "r";
var ORG_LOCATION_ID = "o";
var SLOT_NODE_ID = "s";
var TEXT_NODE_ID = "t";
var COMMENT_NODE_ID = "c";
var HYDRATE_ID = "s-id";
var HYDRATED_STYLE_ID = "sty-id";
var HYDRATE_CHILD_ID = "c-id";
var HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
var RINDO_DOC_DATA = "_rindoDocData";
var DEFAULT_DOC_DATA = {
hostIds: 0,
rootLevelIds: 0,
staticComponents: /* @__PURE__ */ new Set()
};
var SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
var XLINK_NS = "http://www.w3.org/1999/xlink";
var FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
"formAssociatedCallback",
"formResetCallback",
"formDisabledCallback",
"formStateRestoreCallback"
];
// src/runtime/slot-polyfill-utils.ts
var import_app_data = require("@rindo/core/internal/app-data");
var updateFallbackSlotVisibility = (elm) => {
const childNodes = elm.__childNodes || elm.childNodes;
if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") {
getHostSlotNodes(childNodes, elm.tagName).forEach((slotNode) => {
var _a;
if (slotNode.nodeType === 1 /* ElementNode */ && slotNode.tagName === "SLOT-FB") {
if ((_a = getHostSlotChildNodes(slotNode, slotNode["s-sn"], false)) == null ? void 0 : _a.length) {
slotNode.hidden = true;
} else {
slotNode.hidden = false;
}
}
});
}
for (const childNode of childNodes) {
if (childNode.nodeType === 1 /* ElementNode */ && (childNode.__childNodes || childNode.childNodes).length) {
updateFallbackSlotVisibility(childNode);
}
}
};
var getSlottedChildNodes = (childNodes) => {
const result = [];
for (let i2 = 0; i2 < childNodes.length; i2++) {
const slottedNode = childNodes[i2]["s-nr"];
if (slottedNode && slottedNode.isConnected) {
result.push(slottedNode);
}
}
return result;
};
var getHostSlotNodes = (childNodes, hostName, slotName) => {
let i2 = 0;
let slottedNodes = [];
let childNode;
for (; i2 < childNodes.length; i2++) {
childNode = childNodes[i2];
if (childNode["s-sr"] && childNode["s-hn"] === hostName && (!slotName || childNode["s-sn"] === slotName)) {
slottedNodes.push(childNode);
if (typeof slotName !== "undefined") return slottedNodes;
}
slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
}
return slottedNodes;
};
var getHostSlotChildNodes = (node, slotName, includeSlot = true) => {
const childNodes = [];
if (includeSlot && node["s-sr"] || !node["s-sr"]) childNodes.push(node);
while ((node = node.nextSibling) && node["s-sn"] === slotName) {
childNodes.push(node);
}
return childNodes;
};
var isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
if (nodeToRelocate.getAttribute("slot") === null && slotName === "") {
return true;
}
if (nodeToRelocate.getAttribute("slot") === slotName) {
return true;
}
return false;
}
if (nodeToRelocate["s-sn"] === slotName) {
return true;
}
return slotName === "";
};
var addSlotRelocateNode = (newChild, slotNode, prepend, position) => {
let slottedNodeLocation;
if (newChild["s-ol"] && newChild["s-ol"].isConnected) {
slottedNodeLocation = newChild["s-ol"];
} else {
slottedNodeLocation = document.createTextNode("");
slottedNodeLocation["s-nr"] = newChild;
}
if (!slotNode["s-cr"] || !slotNode["s-cr"].parentNode) return;
const parent = slotNode["s-cr"].parentNode;
const appendMethod = prepend ? parent.__prepend || parent.prepend : parent.__appendChild || parent.appendChild;
if (typeof position !== "undefined") {
if (import_app_data.BUILD.hydrateClientSide) {
slottedNodeLocation["s-oo"] = position;
const childNodes = parent.__childNodes || parent.childNodes;
const slotRelocateNodes = [slottedNodeLocation];
childNodes.forEach((n) => {
if (n["s-nr"]) slotRelocateNodes.push(n);
});
slotRelocateNodes.sort((a, b) => {
if (!a["s-oo"] || a["s-oo"] < b["s-oo"]) return -1;
else if (!b["s-oo"] || b["s-oo"] < a["s-oo"]) return 1;
return 0;
});
slotRelocateNodes.forEach((n) => appendMethod.call(parent, n));
}
} else {
appendMethod.call(parent, slottedNodeLocation);
}
newChild["s-ol"] = slottedNodeLocation;
newChild["s-sh"] = slotNode["s-hn"];
};
var getSlotName = (node) => node["s-sn"] || node.nodeType === 1 && node.getAttribute("slot") || "";
// src/runtime/vdom/vdom-render.ts
var import_app_data5 = require("@rindo/core/internal/app-data");
// src/runtime/vdom/h.ts
var import_app_data2 = require("@rindo/core/internal/app-data");
var h = (nodeName, vnodeData, ...children) => {
let child = null;
let key = null;
let slotName = null;
let simple = false;
let lastSimple = false;
const vNodeChildren = [];
const walk = (c) => {
for (let i2 = 0; i2 < c.length; i2++) {
child = c[i2];
if (Array.isArray(child)) {
walk(child);
} else if (child != null && typeof child !== "boolean") {
if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
child = String(child);
} else if (import_app_data2.BUILD.isDev && typeof nodeName !== "function" && child.$flags$ === void 0) {
consoleDevError(`vNode passed as children has unexpected type.
Make sure it's using the correct h() function.
Empty objects can also be the cause, look for JSX comments that became objects.`);
}
if (simple && lastSimple) {
vNodeChildren[vNodeChildren.length - 1].$text$ += child;
} else {
vNodeChildren.push(simple ? newVNode(null, child) : child);
}
lastSimple = simple;
}
}
};
walk(children);
if (vnodeData) {
if (import_app_data2.BUILD.isDev && nodeName === "input") {
validateInputProperties(vnodeData);
}
if (import_app_data2.BUILD.vdomKey && vnodeData.key) {
key = vnodeData.key;
}
if (import_app_data2.BUILD.slotRelocation && vnodeData.name) {
slotName = vnodeData.name;
}
if (import_app_data2.BUILD.vdomClass) {
const classData = vnodeData.className || vnodeData.class;
if (classData) {
vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
}
}
}
if (import_app_data2.BUILD.isDev && vNodeChildren.some(isHost)) {
consoleDevError(`The <Host> must be the single root component. Make sure:
- You are NOT using hostData() and <Host> in the same component.
- <Host> is used once, and it's the single root component of the render() function.`);
}
if (import_app_data2.BUILD.vdomFunctional && typeof nodeName === "function") {
return nodeName(
vnodeData === null ? {} : vnodeData,
vNodeChildren,
vdomFnUtils
);
}
const vnode = newVNode(nodeName, null);
vnode.$attrs$ = vnodeData;
if (vNodeChildren.length > 0) {
vnode.$children$ = vNodeChildren;
}
if (import_app_data2.BUILD.vdomKey) {
vnode.$key$ = key;
}
if (import_app_data2.BUILD.slotRelocation) {
vnode.$name$ = slotName;
}
return vnode;
};
var newVNode = (tag, text) => {
const vnode = {
$flags$: 0,
$tag$: tag,
$text$: text,
$elm$: null,
$children$: null
};
if (import_app_data2.BUILD.vdomAttribute) {
vnode.$attrs$ = null;
}
if (import_app_data2.BUILD.vdomKey) {
vnode.$key$ = null;
}
if (import_app_data2.BUILD.slotRelocation) {
vnode.$name$ = null;
}
return vnode;
};
var Host = {};
var isHost = (node) => node && node.$tag$ === Host;
var vdomFnUtils = {
forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
};
var convertToPublic = (node) => ({
vattrs: node.$attrs$,
vchildren: node.$children$,
vkey: node.$key$,
vname: node.$name$,
vtag: node.$tag$,
vtext: node.$text$
});
var convertToPrivate = (node) => {
if (typeof node.vtag === "function") {
const vnodeData = { ...node.vattrs };
if (node.vkey) {
vnodeData.key = node.vkey;
}
if (node.vname) {
vnodeData.name = node.vname;
}
return h(node.vtag, vnodeData, ...node.vchildren || []);
}
const vnode = newVNode(node.vtag, node.vtext);
vnode.$attrs$ = node.vattrs;
vnode.$children$ = node.vchildren;
vnode.$key$ = node.vkey;
vnode.$name$ = node.vname;
return vnode;
};
var validateInputProperties = (inputElm) => {
const props = Object.keys(inputElm);
const value = props.indexOf("value");
if (value === -1) {
return;
}
const typeIndex = props.indexOf("type");
const minIndex = props.indexOf("min");
const maxIndex = props.indexOf("max");
const stepIndex = props.indexOf("step");
if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
}
};
// src/runtime/vdom/update-element.ts
var import_app_data4 = require("@rindo/core/internal/app-data");
// src/runtime/vdom/set-accessor.ts
var import_app_data3 = require("@rindo/core/internal/app-data");
var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
if (oldValue !== newValue) {
let isProp = isMemberInElement(elm, memberName);
let ln = memberName.toLowerCase();
if (import_app_data3.BUILD.vdomClass && memberName === "class") {
const classList = elm.classList;
const oldClasses = parseClassList(oldValue);
let newClasses = parseClassList(newValue);
if (elm["s-si"]) {
newClasses.push(elm["s-si"]);
oldClasses.forEach((c) => {
if (c.startsWith(elm["s-si"])) newClasses.push(c);
});
newClasses = [...new Set(newClasses)];
classList.add(...newClasses);
delete elm["s-si"];
} else {
classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
}
} else if (import_app_data3.BUILD.vdomStyle && memberName === "style") {
if (import_app_data3.BUILD.updatable) {
for (const prop in oldValue) {
if (!newValue || newValue[prop] == null) {
if (!import_app_data3.BUILD.hydrateServerSide && prop.includes("-")) {
elm.style.removeProperty(prop);
} else {
elm.style[prop] = "";
}
}
}
}
for (const prop in newValue) {
if (!oldValue || newValue[prop] !== oldValue[prop]) {
if (!import_app_data3.BUILD.hydrateServerSide && prop.includes("-")) {
elm.style.setProperty(prop, newValue[prop]);
} else {
elm.style[prop] = newValue[prop];
}
}
}
} else if (import_app_data3.BUILD.vdomKey && memberName === "key") {
} else if (import_app_data3.BUILD.vdomRef && memberName === "ref") {
if (newValue) {
newValue(elm);
}
} else if (import_app_data3.BUILD.vdomListener && (import_app_data3.BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
if (memberName[2] === "-") {
memberName = memberName.slice(3);
} else if (isMemberInElement(win, ln)) {
memberName = ln.slice(2);
} else {
memberName = ln[2] + memberName.slice(3);
}
if (oldValue || newValue) {
const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
if (oldValue) {
plt.rel(elm, memberName, oldValue, capture);
}
if (newValue) {
plt.ael(elm, memberName, newValue, capture);
}
}
} else if (import_app_data3.BUILD.vdomPropOrAttr) {
const isComplex = isComplexType(newValue);
if ((isProp || isComplex && newValue !== null) && !isSvg) {
try {
if (!elm.tagName.includes("-")) {
const n = newValue == null ? "" : newValue;
if (memberName === "list") {
isProp = false;
} else if (oldValue == null || elm[memberName] != n) {
if (typeof elm.__lookupSetter__(memberName) === "function") {
elm[memberName] = n;
} else {
elm.setAttribute(memberName, n);
}
}
} else {
elm[memberName] = newValue;
}
} catch (e) {
}
}
let xlink = false;
if (import_app_data3.BUILD.vdomXlink) {
if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
memberName = ln;
xlink = true;
}
}
if (newValue == null || newValue === false) {
if (newValue !== false || elm.getAttribute(memberName) === "") {
if (import_app_data3.BUILD.vdomXlink && xlink) {
elm.removeAttributeNS(XLINK_NS, memberName);
} else {
elm.removeAttribute(memberName);
}
}
} else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
newValue = newValue === true ? "" : newValue;
if (import_app_data3.BUILD.vdomXlink && xlink) {
elm.setAttributeNS(XLINK_NS, memberName, newValue);
} else {
elm.setAttribute(memberName, newValue);
}
}
}
}
};
var parseClassListRegex = /\s/;
var parseClassList = (value) => {
if (typeof value === "object" && "baseVal" in value) {
value = value.baseVal;
}
if (!value) {
return [];
}
return value.split(parseClassListRegex);
};
var CAPTURE_EVENT_SUFFIX = "Capture";
var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
// src/runtime/vdom/update-element.ts
var updateElement = (oldVnode, newVnode, isSvgMode2) => {
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
const newVnodeAttrs = newVnode.$attrs$ || {};
if (import_app_data4.BUILD.updatable) {
for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
if (!(memberName in newVnodeAttrs)) {
setAccessor(elm, memberName, oldVnodeAttrs[memberName], void 0, isSvgMode2, newVnode.$flags$);
}
}
}
for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode2, newVnode.$flags$);
}
};
function sortedAttrNames(attrNames) {
return attrNames.includes("ref") ? (
// we need to sort these to ensure that `'ref'` is the last attr
[...attrNames.filter((attr) => attr !== "ref"), "ref"]
) : (
// no need to sort, return the original array
attrNames
);
}
// src/runtime/vdom/vdom-render.ts
var scopeId;
var contentRef;
var hostTagName;
var useNativeShadowDom = false;
var checkSlotFallbackVisibility = false;
var checkSlotRelocate = false;
var isSvgMode = false;
var createElm = (oldParentVNode, newParentVNode, childIndex) => {
var _a;
const newVNode2 = newParentVNode.$children$[childIndex];
let i2 = 0;
let elm;
let childNode;
let oldVNode;
if (import_app_data5.BUILD.slotRelocation && !useNativeShadowDom) {
checkSlotRelocate = true;
if (newVNode2.$tag$ === "slot") {
newVNode2.$flags$ |= newVNode2.$children$ ? (
// slot element has fallback content
// still create an element that "mocks" the slot element
2 /* isSlotFallback */
) : (
// slot element does not have fallback content
// create an html comment we'll use to always reference
// where actual slot content should sit next to
1 /* isSlotReference */
);
}
}
if (import_app_data5.BUILD.isDev && newVNode2.$elm$) {
consoleDevError(
`The JSX ${newVNode2.$text$ !== null ? `"${newVNode2.$text$}" text` : `"${newVNode2.$tag$}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://rindojs.web.app/docs/templating-jsx#avoid-shared-jsx-nodes`
);
}
if (import_app_data5.BUILD.vdomText && newVNode2.$text$ !== null) {
elm = newVNode2.$elm$ = doc.createTextNode(newVNode2.$text$);
} else if (import_app_data5.BUILD.slotRelocation && newVNode2.$flags$ & 1 /* isSlotReference */) {
elm = newVNode2.$elm$ = import_app_data5.BUILD.isDebug || import_app_data5.BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode2) : doc.createTextNode("");
} else {
if (import_app_data5.BUILD.svg && !isSvgMode) {
isSvgMode = newVNode2.$tag$ === "svg";
}
elm = newVNode2.$elm$ = import_app_data5.BUILD.svg ? doc.createElementNS(
isSvgMode ? SVG_NS : HTML_NS,
!useNativeShadowDom && import_app_data5.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
) : doc.createElement(
!useNativeShadowDom && import_app_data5.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
);
if (import_app_data5.BUILD.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
isSvgMode = false;
}
if (import_app_data5.BUILD.vdomAttribute) {
updateElement(null, newVNode2, isSvgMode);
}
if (import_app_data5.BUILD.scoped && isDef(scopeId) && elm["s-si"] !== scopeId) {
elm.classList.add(elm["s-si"] = scopeId);
}
if (newVNode2.$children$) {
for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
childNode = createElm(oldParentVNode, newVNode2, i2);
if (childNode) {
elm.appendChild(childNode);
}
}
}
if (import_app_data5.BUILD.svg) {
if (newVNode2.$tag$ === "svg") {
isSvgMode = false;
} else if (elm.tagName === "foreignObject") {
isSvgMode = true;
}
}
}
elm["s-hn"] = hostTagName;
if (import_app_data5.BUILD.slotRelocation) {
if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
elm["s-sr"] = true;
elm["s-cr"] = contentRef;
elm["s-sn"] = newVNode2.$name$ || "";
elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
if (import_app_data5.BUILD.experimentalSlotFixes) {
relocateToHostRoot(oldParentVNode.$elm$);
} else {
putBackInOriginalLocation(oldParentVNode.$elm$, false);
}
}
if (import_app_data5.BUILD.scoped) {
addRemoveSlotScopedClass(contentRef, elm, newParentVNode.$elm$, oldParentVNode == null ? void 0 : oldParentVNode.$elm$);
}
}
}
return elm;
};
var relocateToHostRoot = (parentElm) => {
plt.$flags$ |= 1 /* isTmpDisconnected */;
const host = parentElm.closest(hostTagName.toLowerCase());
if (host != null) {
const contentRefNode = Array.from(host.__childNodes || host.childNodes).find(
(ref) => ref["s-cr"]
);
const childNodeArray = Array.from(
parentElm.__childNodes || parentElm.childNodes
);
for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
if (childNode["s-sh"] != null) {
insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
childNode["s-sh"] = void 0;
checkSlotRelocate = true;
}
}
}
plt.$flags$ &= ~1 /* isTmpDisconnected */;
};
var putBackInOriginalLocation = (parentElm, recursive) => {
plt.$flags$ |= 1 /* isTmpDisconnected */;
const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
if (parentElm["s-sr"] && import_app_data5.BUILD.experimentalSlotFixes) {
let node = parentElm;
while (node = node.nextSibling) {
if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
oldSlotChildNodes.push(node);
}
}
}
for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
const childNode = oldSlotChildNodes[i2];
if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
insertBefore(referenceNode(childNode).parentNode, childNode, referenceNode(childNode));
childNode["s-ol"].remove();
childNode["s-ol"] = void 0;
childNode["s-sh"] = void 0;
checkSlotRelocate = true;
}
if (recursive) {
putBackInOriginalLocation(childNode, recursive);
}
}
plt.$flags$ &= ~1 /* isTmpDisconnected */;
};
var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
let containerElm = import_app_data5.BUILD.slotRelocation && parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
let childNode;
if (import_app_data5.BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
containerElm = containerElm.shadowRoot;
}
for (; startIdx <= endIdx; ++startIdx) {
if (vnodes[startIdx]) {
childNode = createElm(null, parentVNode, startIdx);
if (childNode) {
vnodes[startIdx].$elm$ = childNode;
insertBefore(containerElm, childNode, import_app_data5.BUILD.slotRelocation ? referenceNode(before) : before);
}
}
}
};
var removeVnodes = (vnodes, startIdx, endIdx) => {
for (let index = startIdx; index <= endIdx; ++index) {
const vnode = vnodes[index];
if (vnode) {
const elm = vnode.$elm$;
nullifyVNodeRefs(vnode);
if (elm) {
if (import_app_data5.BUILD.slotRelocation) {
checkSlotFallbackVisibility = true;
if (elm["s-ol"]) {
elm["s-ol"].remove();
} else {
putBackInOriginalLocation(elm, true);
}
}
elm.remove();
}
}
}
};
var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
let oldStartIdx = 0;
let newStartIdx = 0;
let idxInOld = 0;
let i2 = 0;
let oldEndIdx = oldCh.length - 1;
let oldStartVnode = oldCh[0];
let oldEndVnode = oldCh[oldEndIdx];
let newEndIdx = newCh.length - 1;
let newStartVnode = newCh[0];
let newEndVnode = newCh[newEndIdx];
let node;
let elmToMove;
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
if (oldStartVnode == null) {
oldStartVnode = oldCh[++oldStartIdx];
} else if (oldEndVnode == null) {
oldEndVnode = oldCh[--oldEndIdx];
} else if (newStartVnode == null) {
newStartVnode = newCh[++newStartIdx];
} else if (newEndVnode == null) {
newEndVnode = newCh[--newEndIdx];
} else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
patch(oldStartVnode, newStartVnode, isInitialRender);
oldStartVnode = oldCh[++oldStartIdx];
newStartVnode = newCh[++newStartIdx];
} else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
patch(oldEndVnode, newEndVnode, isInitialRender);
oldEndVnode = oldCh[--oldEndIdx];
newEndVnode = newCh[--newEndIdx];
} else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
if (import_app_data5.BUILD.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
}
patch(oldStartVnode, newEndVnode, isInitialRender);
insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
oldStartVnode = oldCh[++oldStartIdx];
newEndVnode = newCh[--newEndIdx];
} else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
if (import_app_data5.BUILD.slotRelocation && (oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
}
patch(oldEndVnode, newStartVnode, isInitialRender);
insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
oldEndVnode = oldCh[--oldEndIdx];
newStartVnode = newCh[++newStartIdx];
} else {
idxInOld = -1;
if (import_app_data5.BUILD.vdomKey) {
for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
idxInOld = i2;
break;
}
}
}
if (import_app_data5.BUILD.vdomKey && idxInOld >= 0) {
elmToMove = oldCh[idxInOld];
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
} else {
patch(elmToMove, newStartVnode, isInitialRender);
oldCh[idxInOld] = void 0;
node = elmToMove.$elm$;
}
newStartVnode = newCh[++newStartIdx];
} else {
node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
newStartVnode = newCh[++newStartIdx];
}
if (node) {
if (import_app_data5.BUILD.slotRelocation) {
insertBefore(
referenceNode(oldStartVnode.$elm$).parentNode,
node,
referenceNode(oldStartVnode.$elm$)
);
} else {
insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
}
}
}
}
if (oldStartIdx > oldEndIdx) {
addVnodes(
parentElm,
newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
newVNode2,
newCh,
newStartIdx,
newEndIdx
);
} else if (import_app_data5.BUILD.updatable && newStartIdx > newEndIdx) {
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
}
};
var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
if (leftVNode.$tag$ === rightVNode.$tag$) {
if (import_app_data5.BUILD.slotRelocation && leftVNode.$tag$ === "slot") {
return leftVNode.$name$ === rightVNode.$name$;
}
if (import_app_data5.BUILD.vdomKey && !isInitialRender) {
return leftVNode.$key$ === rightVNode.$key$;
}
if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
leftVNode.$key$ = rightVNode.$key$;
}
return true;
}
return false;
};
var referenceNode = (node) => node && node["s-ol"] || node;
var patch = (oldVNode, newVNode2, isInitialRender = false) => {
const elm = newVNode2.$elm$ = oldVNode.$elm$;
const oldChildren = oldVNode.$children$;
const newChildren = newVNode2.$children$;
const tag = newVNode2.$tag$;
const text = newVNode2.$text$;
let defaultHolder;
if (!import_app_data5.BUILD.vdomText || text === null) {
if (import_app_data5.BUILD.svg) {
isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
}
if (import_app_data5.BUILD.vdomAttribute || import_app_data5.BUILD.reflect) {
if (import_app_data5.BUILD.slot && tag === "slot" && !useNativeShadowDom) {
if (import_app_data5.BUILD.experimentalSlotFixes && oldVNode.$name$ !== newVNode2.$name$) {
newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
relocateToHostRoot(newVNode2.$elm$.parentElement);
}
} else {
updateElement(oldVNode, newVNode2, isSvgMode);
}
}
if (import_app_data5.BUILD.updatable && oldChildren !== null && newChildren !== null) {
updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
} else if (newChildren !== null) {
if (import_app_data5.BUILD.updatable && import_app_data5.BUILD.vdomText && oldVNode.$text$ !== null) {
elm.textContent = "";
}
addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
} else if (
// don't do this on initial render as it can cause non-hydrated content to be removed
!isInitialRender && import_app_data5.BUILD.updatable && oldChildren !== null
) {
removeVnodes(oldChildren, 0, oldChildren.length - 1);
}
if (import_app_data5.BUILD.svg && isSvgMode && tag === "svg") {
isSvgMode = false;
}
} else if (import_app_data5.BUILD.vdomText && import_app_data5.BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) {
defaultHolder.parentNode.textContent = text;
} else if (import_app_data5.BUILD.vdomText && oldVNode.$text$ !== text) {
elm.data = text;
}
};
var relocateNodes = [];
var markSlotContentForRelocation = (elm) => {
let node;
let hostContentNodes;
let j;
const children = elm.__childNodes || elm.childNodes;
for (const childNode of children) {
if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
hostContentNodes = node.parentNode.__childNodes || node.parentNode.childNodes;
const slotName = childNode["s-sn"];
for (j = hostContentNodes.length - 1; j >= 0; j--) {
node = hostContentNodes[j];
if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!import_app_data5.BUILD.experimentalSlotFixes || !node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
if (isNodeLocatedInSlot(node, slotName)) {
let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
checkSlotFallbackVisibility = true;
node["s-sn"] = node["s-sn"] || slotName;
if (relocateNodeData) {
relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
relocateNodeData.$slotRefNode$ = childNode;
} else {
node["s-sh"] = childNode["s-hn"];
relocateNodes.push({
$slotRefNode$: childNode,
$nodeToRelocate$: node
});
}
if (node["s-sr"]) {
relocateNodes.map((relocateNode) => {
if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
if (relocateNodeData && !relocateNode.$slotRefNode$) {
relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
}
}
});
}
} else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
relocateNodes.push({
$nodeToRelocate$: node
});
}
}
}
}
if (childNode.nodeType === 1 /* ElementNode */) {
markSlotContentForRelocation(childNode);
}
}
};
var nullifyVNodeRefs = (vNode) => {
if (import_app_data5.BUILD.vdomRef) {
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
}
};
var insertBefore = (parent, newNode, reference) => {
if (import_app_data5.BUILD.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) {
addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
}
const inserted = parent == null ? void 0 : parent.insertBefore(newNode, reference);
return inserted;
};
function addRemoveSlotScopedClass(reference, slotNode, newParent, oldParent) {
var _a;
let scopeId2;
if (reference && typeof slotNode["s-sn"] === "string" && !!slotNode["s-sr"] && reference.parentNode && reference.parentNode["s-sc"] && (scopeId2 = slotNode["s-si"] || reference.parentNode["s-sc"])) {
const scopeName = slotNode["s-sn"];
const hostName = slotNode["s-hn"];
(_a = newParent.classList) == null ? void 0 : _a.add(scopeId2 + "-s");
if (oldParent && oldParent.classList.contains(scopeId2 + "-s")) {
let child = (oldParent.__childNodes || oldParent.childNodes)[0];
let found = false;
while (child) {
if (child["s-sn"] !== scopeName && child["s-hn"] === hostName && !!child["s-sr"]) {
found = true;
break;
}
child = child.nextSibling;
}
if (!found) oldParent.classList.remove(scopeId2 + "-s");
}
}
}
var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
var _a, _b, _c, _d, _e;
const hostElm = hostRef.$hostElement$;
const cmpMeta = hostRef.$cmpMeta$;
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
hostTagName = hostElm.tagName;
if (import_app_data5.BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
throw new Error(`The <Host> must be the single root component.
Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
The render() function should look like this instead:
render() {
// Do not return an array
return (
<Host>{content}</Host>
);
}
`);
}
if (import_app_data5.BUILD.reflect && cmpMeta.$attrsToReflect$) {
rootVnode.$attrs$ = rootVnode.$attrs$ || {};
cmpMeta.$attrsToReflect$.map(
([propName, attribute]) => rootVnode.$attrs$[attribute] = hostElm[propName]
);
}
if (isInitialLoad && rootVnode.$attrs$) {
for (const key of Object.keys(rootVnode.$attrs$)) {
if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
rootVnode.$attrs$[key] = hostElm[key];
}
}
}
rootVnode.$tag$ = null;
rootVnode.$flags$ |= 4 /* isHost */;
hostRef.$vnode$ = rootVnode;
rootVnode.$elm$ = oldVNode.$elm$ = import_app_data5.BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm;
if (import_app_data5.BUILD.scoped || import_app_data5.BUILD.shadowDom) {
scopeId = hostElm["s-sc"];
}
useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
if (import_app_data5.BUILD.slotRelocation) {
contentRef = hostElm["s-cr"];
checkSlotFallbackVisibility = false;
}
patch(oldVNode, rootVnode, isInitialLoad);
if (import_app_data5.BUILD.slotRelocation) {
plt.$flags$ |= 1 /* isTmpDisconnected */;
if (checkSlotRelocate) {
markSlotContentForRelocation(rootVnode.$elm$);
for (const relocateData of relocateNodes) {
const nodeToRelocate = relocateData.$nodeToRelocate$;
if (!nodeToRelocate["s-ol"]) {
const orgLocationNode = import_app_data5.BUILD.isDebug || import_app_data5.BUILD.hydrateServerSide ? originalLocationDebugNode(nodeToRelocate) : doc.createTextNode("");
orgLocationNode["s-nr"] = nodeToRelocate;
insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
}
}
for (const relocateData of relocateNodes) {
const nodeToRelocate = relocateData.$nodeToRelocate$;
const slotRefNode = relocateData.$slotRefNode$;
if (slotRefNode) {
const parentNodeRef = slotRefNode.parentNode;
let insertBeforeNode = slotRefNode.nextSibling;
if (!import_app_data5.BUILD.hydrateServerSide && (!import_app_data5.BUILD.experimentalSlotFixes || insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */)) {
let orgLocationNode = (_a = nodeToRelocate["s-ol"]) == null ? void 0 : _a.previousSibling;
while (orgLocationNode) {
let refNode = (_b = orgLocationNode["s-nr"]) != null ? _b : null;
if (refNode && refNode["s-sn"] === nodeToRelocate["s-sn"] && parentNodeRef === refNode.parentNode) {
refNode = refNode.nextSibling;
while (refN