🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@pinegrow/vite-plugin

Package Overview
Dependencies
Maintainers
3
Versions
333
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pinegrow/vite-plugin - npm Package Compare versions

Comparing version
3.0.77-alpha.0
to
3.0.77-beta.0
+309
dist/adapters/shared/mapping/runtime/runtime.js
const documentPositionPreceding = 2
const documentPositionFollowing = 4
const createFallbackComputed = getter => ({
get value() {
return getter()
},
})
const createFallbackRef = value => ({ value })
const readWatchSource = source => {
if (typeof source === 'function') {
return source()
}
return source?.value
}
const createFallbackWatch = (source, callback, options = {}) => {
if (options.immediate && typeof callback === 'function') {
callback(readWatchSource(source), undefined)
}
return () => {}
}
const isMapLike = value =>
value &&
typeof value.get === 'function' &&
typeof value.set === 'function' &&
typeof value.delete === 'function' &&
typeof value.entries === 'function'
const createSourceDomTreeScopes = entryKind => ({
pageTree: entryKind === 'source-node',
appTree: entryKind === 'component-boundary' || entryKind === 'page-root',
})
const normalizeSourceDomCacheEntries = entries => Array.isArray(entries) ? entries : []
const getSourceDomBoundaryElement = (elCacheObj, fallbackEl = null) =>
elCacheObj.firstEl || elCacheObj.el || fallbackEl || null
const getSourceDomBoundaryLastElement = (elCacheObj, fallbackEl = null) =>
elCacheObj.lastEl || elCacheObj.firstEl || elCacheObj.el || fallbackEl || null
const getSourceDomSourceInspector = (elCacheObj, fallbackEl = null) => {
const props = elCacheObj.vnode?.props
const firstEl = getSourceDomBoundaryElement(elCacheObj, fallbackEl)
return (
elCacheObj.sourceInspector ||
props?.['data-v-inspector'] ||
firstEl?.getAttribute?.('data-v-inspector') ||
fallbackEl?.getAttribute?.('data-v-inspector') ||
null
)
}
const isBoundaryConnected = (elCacheObj, fallbackEl = null) => {
const firstEl = getSourceDomBoundaryElement(elCacheObj, fallbackEl)
const lastEl = getSourceDomBoundaryLastElement(elCacheObj, fallbackEl)
return Boolean(firstEl?.isConnected || lastEl?.isConnected || fallbackEl?.isConnected)
}
const isBoundaryMounted = elCacheObj => {
return elCacheObj.instance.isMounted !== false && elCacheObj.instance.isUnmounted !== true
}
const getBoundaryId = elCacheObj => {
const file = elCacheObj.localFile || ''
const uid = elCacheObj.instance.uid ?? ''
const key = elCacheObj.key ?? ''
const pgId = elCacheObj.sourcePgId ?? elCacheObj.pgId ?? elCacheObj.sourceId ?? elCacheObj.source?.id ?? ''
return [file, uid, key, pgId].join('::')
}
const createAppTreeBoundariesComputed = (elCache, computedFromContext = createFallbackComputed) =>
computedFromContext(() => {
const boundariesByRuntimeKey = new Map()
for (let [el, elCacheNodes] of elCache.entries()) {
normalizeSourceDomCacheEntries(elCacheNodes).forEach(elCacheObj => {
if (
!isBoundaryMounted(elCacheObj) ||
!isBoundaryConnected(elCacheObj, el) ||
elCacheObj.treeScopes.appTree !== true ||
!elCacheObj.localFile
) {
return
}
const localFile = elCacheObj.localFile
const firstEl = getSourceDomBoundaryElement(elCacheObj, el)
const lastEl = getSourceDomBoundaryLastElement(elCacheObj, el)
if (!firstEl) {
return
}
if (elCacheObj.isIsland) {
const childEl = firstEl.firstElementChild
if (childEl && elCache.has(childEl)) {
return
}
}
const sourcePgId = elCacheObj.sourcePgId ?? null
const renderPgId = !sourcePgId
? elCacheObj.renderPgId ?? elCacheObj.pgId ?? null
: elCacheObj.renderPgId ?? null
const candidate = {
...elCacheObj,
sourceElCacheObj: elCacheObj,
appTreeBoundary: true,
appTreeBoundaryId: null,
localFile,
firstEl,
lastEl,
sourcePgId,
renderPgId,
sourceInspector: getSourceDomSourceInspector(elCacheObj, el),
}
// Start App Tree runtime-boundary dedupe.
const runtimeKey = [localFile || '', candidate.instance.uid, candidate.key ?? ''].join('::')
const existingBoundary = boundariesByRuntimeKey.get(runtimeKey)
let boundary = candidate
if (existingBoundary) {
const preferred =
candidate.sourcePgId && !existingBoundary.sourcePgId ? candidate : existingBoundary
const fallback = preferred === existingBoundary ? candidate : existingBoundary
const sourceElCacheObj = preferred.sourcePgId
? preferred.sourceElCacheObj || preferred
: fallback.sourcePgId
? fallback.sourceElCacheObj || fallback
: preferred.sourceElCacheObj || fallback.sourceElCacheObj || preferred
const sourcePgId = preferred.sourcePgId ?? fallback.sourcePgId ?? null
const renderPgId = preferred.renderPgId ?? fallback.renderPgId ?? null
const sourceInspector = preferred.sourceInspector ?? fallback.sourceInspector ?? null
boundary = {
...fallback,
...preferred,
sourceElCacheObj,
sourcePgId,
renderPgId,
sourceInspector,
pgId: sourcePgId ?? preferred.pgId ?? fallback.pgId ?? null,
firstEl: preferred.firstEl || fallback.firstEl,
lastEl: preferred.lastEl || fallback.lastEl,
el: preferred.el || fallback.el,
localFile: preferred.localFile || fallback.localFile,
}
}
boundariesByRuntimeKey.set(runtimeKey, boundary)
// End App Tree runtime-boundary dedupe.
})
}
const boundaries = Array.from(boundariesByRuntimeKey.values()).map(boundary => {
const boundaryId = getBoundaryId(boundary)
return {
...boundary,
appTreeBoundaryId: boundaryId,
}
})
return boundaries.sort((a, b) => {
const aEl = getSourceDomBoundaryElement(a)
const bEl = getSourceDomBoundaryElement(b)
if (!aEl?.compareDocumentPosition || !bEl) {
return 0
}
const position = aEl.compareDocumentPosition(bEl)
if (position & documentPositionPreceding) {
return 1
}
if (position & documentPositionFollowing) {
return -1
}
return 0
})
})
const createSourceDomReactiveMap = (pinegrow, value) => {
const map = isMapLike(value) ? value : new Map()
const reactiveFromContext = pinegrow?.reactiveFromContext || (value => value)
return reactiveFromContext(map)
}
const ensurePinegrowSourceDomRuntime = (win, context = {}) => {
if (!win) {
return null
}
if (!win.pinegrow) {
win.pinegrow = {}
}
const pinegrow = win.pinegrow
const reactiveFromContext = context.reactiveFromContext || pinegrow.reactiveFromContext || (value => value)
const refFromContext = context.refFromContext || pinegrow.refFromContext || createFallbackRef
const computedFromContext = context.computedFromContext || pinegrow.computedFromContext || createFallbackComputed
const watchFromContext = context.watchFromContext || pinegrow.watchFromContext || createFallbackWatch
const existingElCache = isMapLike(pinegrow.elCache) ? pinegrow.elCache : new Map()
const elCache = reactiveFromContext(existingElCache)
if (
pinegrow.elCache !== elCache ||
!pinegrow.appTreeBoundariesComputed ||
pinegrow.reactiveFromContext !== reactiveFromContext ||
pinegrow.refFromContext !== refFromContext ||
pinegrow.computedFromContext !== computedFromContext ||
pinegrow.watchFromContext !== watchFromContext
) {
Object.assign(pinegrow, {
elCache,
appTreeBoundariesComputed: createAppTreeBoundariesComputed(elCache, computedFromContext),
reactiveFromContext,
refFromContext,
computedFromContext,
watchFromContext,
})
}
return pinegrow
}
const createSourceDomCacheEntry = fields => {
const sourceRange = fields.sourceRange ?? null
const entryKind = fields.entryKind
return {
el: fields.el,
framework: fields.framework,
entryKind,
treeScopes: fields.treeScopes || createSourceDomTreeScopes(entryKind),
isRootFragment: Boolean(fields.isRootFragment),
rootEl: fields.rootEl ?? null,
vnode: fields.vnode ?? null,
instance: fields.instance,
isFragment: Boolean(fields.isFragment),
firstEl: fields.firstEl ?? null,
lastEl: fields.lastEl ?? null,
pgId: fields.pgId ?? null,
sourceId: fields.sourceId ?? null,
sourcePgId: fields.sourcePgId ?? null,
renderPgId: fields.renderPgId ?? null,
sourceInspector: fields.sourceInspector ?? null,
sourceFile: fields.sourceFile ?? null,
key: fields.key ?? null,
localFile: fields.localFile ?? null,
name: fields.name ?? '',
source: fields.source ?? null,
component: fields.component ?? null,
owners: fields.owners ?? [],
sourceRange,
sourceStart: fields.sourceStart ?? sourceRange?.start ?? null,
sourceEnd: fields.sourceEnd ?? sourceRange?.end ?? null,
sourceRangeStatus: fields.sourceRangeStatus ?? sourceRange?.status ?? null,
marker: fields.marker ?? null,
editability: fields.editability ?? null,
attributes: fields.attributes ?? [],
state: fields.state,
isIsland: Boolean(fields.isIsland),
...(fields.extra || {}),
}
}
const upsertSourceDomCacheEntry = (elCache, entry, isSameEntry) => {
const existingEntries = normalizeSourceDomCacheEntries(elCache.get(entry.el))
const matchesEntry = isSameEntry || ((existingEntry, nextEntry) =>
existingEntry.framework === nextEntry.framework &&
existingEntry.sourceId === nextEntry.sourceId &&
existingEntry.localFile === nextEntry.localFile)
const nextEntries = existingEntries.filter(existingEntry => !matchesEntry(existingEntry, entry))
nextEntries.push(entry)
elCache.set(entry.el, nextEntries)
}
export {
createAppTreeBoundariesComputed,
createFallbackComputed,
createFallbackRef,
createFallbackWatch,
createSourceDomCacheEntry,
createSourceDomReactiveMap,
createSourceDomTreeScopes,
ensurePinegrowSourceDomRuntime,
getSourceDomBoundaryElement,
getSourceDomBoundaryLastElement,
getSourceDomSourceInspector,
isMapLike,
normalizeSourceDomCacheEntries,
upsertSourceDomCacheEntry,
}
import {
onBeforeMount,
onMounted,
onBeforeUnmount,
getCurrentInstance,
ref,
reactive,
onUpdated,
computed,
watch,
} from 'vue'
import {
createSourceDomCacheEntry,
createSourceDomTreeScopes,
ensurePinegrowSourceDomRuntime,
getSourceDomSourceInspector as getSourceInspector,
} from '../../../shared/mapping/runtime/runtime.js'
const getVueCacheEntryKind = (isSourceNode, localFile) => {
if (isSourceNode) {
return 'source-node'
}
return localFile ? 'component-boundary' : 'render-node'
}
export function createVueRuntimeBridge() {
const ensurePinegrowVueRuntime = () => {
// conditional
const winObj = window
if (!(winObj?.process?.client && winObj.process.client !== true)) {
ensurePinegrowSourceDomRuntime(winObj, {
reactiveFromContext: reactive,
refFromContext: ref,
computedFromContext: computed,
watchFromContext: watch,
})
}
}
// pgId & key can be optional
const refreshVueSourceDomMapping = (hook, pgId, rootEl, key, localFile, sourceFile) => async vnode => {
if (!vnode) return
if (window?.process?.client && process?.client !== true) return
if (!window.pinegrow) ensurePinegrowVueRuntime()
let el = vnode.el
const instance = vnode.component || vnode.ctx || el.__vueParentComponent
if (!el || !instance) return
try {
if ((key !== null && key !== undefined) || (vnode.key !== null && vnode.key !== undefined)) {
key = vnode.key || key
}
if (!sourceFile) {
localFile = localFile || vnode.type.__file
}
let isRootFragment = false
let isFragment = el.nodeType !== 1
let firstEl,
lastEl,
isIsland = false,
childVNodes = []
// May be an iles Island that wraps components with client directives
if (localFile) {
if (localFile.includes('node_modules/iles') && localFile.includes('Island.vue')) {
// Retain localFiles of iles island to apply to child elements
isIsland = true
}
if (localFile.includes('node_modules')) {
// Ignore SFCs from node_modules
localFile = null
}
}
const localFileFromInstance = instance.type.__file
if (
localFileFromInstance &&
localFileFromInstance.includes('node_modules/iles') &&
localFileFromInstance.includes('Island.vue')
) {
// Retain localFiles of iles island to apply to child elements
isIsland = true
localFile = instance.props.component?.__file || instance.props.importFrom
}
// // Computed props anyway filters out unmounted ones, and we use the local components unmounted hooks to cleanup unmounted nodes. Using the unmounted hook seems to be out of sync when el is reused but instance is remounted.
// if (hook === 'unmounted') {
// if (pinegrow.elCache.has(el)) {
// pinegrow.elCache.delete(el)
// }
// for (let [key, value] of pinegrow.elCache.entries()) {
// if (value.rootEl === rootEl) {
// pinegrow.elCache.delete(key)
// }
// }
// return
// }
// Text/comment node
if (isFragment) {
if (!rootEl) {
// root Fragment
isRootFragment = true
}
function isFragmentEl(instance) {
// return appRecord.options.types.Fragment === instance.subTree?.type
return instance.subTree.el.nodeType !== 1
}
function getRootVNodesFromComponentInstance(instance) {
if (isFragmentEl(instance)) {
return getFragmentRootVNodes(instance.subTree)
}
if (!instance.subTree) return []
return [instance.subTree]
}
function getFragmentRootVNodes(vnode) {
if (!vnode.children) return []
// children is v-if when the vnode has a condition
if (!Array.isArray(vnode.children)) return []
const list = []
for (let i = 0, l = vnode.children.length; i < l; i++) {
const childVnode = vnode.children[i]
if (childVnode.component) {
list.push(...getRootVNodesFromComponentInstance(childVnode.component))
} else if (childVnode) {
list.push(childVnode)
}
}
return list
}
childVNodes = getRootVNodesFromComponentInstance(instance)
if (!childVNodes.length) {
// For NuxtLayout, no childVNodes are returned, the subTree.children is in fact an object {ctx: {}, default: f}
if (el.nextElementSibling) {
const childEl = el.nextElementSibling
firstEl = lastEl = childEl
const childInstance = childEl.$ || childEl.__vueParentComponent
const childVNode = childInstance?.vnode // or subTree?
if (childVNode) {
childVNodes.push(childVNode)
}
}
}
if (childVNodes.length) {
// Filter out recursive vnodes text1 -> div, text1 (happens when text1 is the closest to a fragment with div & slot)
childVNodes = childVNodes.filter(childVNode => childVNode.el !== el)
if (childVNodes.length) {
if (childVNodes.length === 1) {
firstEl = lastEl = childVNodes[0].el
} else {
firstEl = childVNodes[0].el
lastEl = childVNodes[childVNodes.length - 1].el
}
if (firstEl && firstEl.nodeType !== 1) {
firstEl = firstEl.nextElementSibling
}
if (lastEl && lastEl.nodeType !== 1) {
lastEl = lastEl.nextElementSibling
}
}
}
}
if (isIsland && !isRootFragment) {
return
}
const isComponentVNode = Boolean(vnode.component)
const sourceInspector = getSourceInspector({ vnode, el, firstEl, lastEl }, el)
const isSourceNode = Boolean(sourceFile && pgId)
let prevElCacheNodes = pinegrow.elCache.get(el)
let prevElCacheObj = null
let index = -1
if (prevElCacheNodes) {
index = isSourceNode
? prevElCacheNodes.findIndex(
prevElCacheObj =>
prevElCacheObj.instance.uid === instance.uid &&
prevElCacheObj.sourceFile === sourceFile &&
prevElCacheObj.pgId === pgId
)
: prevElCacheNodes.findIndex(elCacheObj => elCacheObj.instance.uid === instance.uid)
if (index > -1) {
prevElCacheObj = prevElCacheNodes[index]
if (!sourceFile) {
localFile = localFile || prevElCacheObj.localFile
}
}
}
localFile = localFile ?? null
const entryKind = getVueCacheEntryKind(isSourceNode, localFile)
let elCacheObj = createSourceDomCacheEntry({
el,
isRootFragment,
rootEl,
vnode,
instance,
isFragment,
firstEl,
lastEl,
pgId,
sourcePgId: !sourceFile && isComponentVNode && pgId ? pgId : null,
renderPgId: !sourceFile && !isComponentVNode && pgId ? pgId : null,
sourceInspector,
sourceFile: isSourceNode ? sourceFile : null,
framework: 'vue',
entryKind,
treeScopes: createSourceDomTreeScopes(entryKind),
key,
localFile,
isIsland,
})
if (prevElCacheNodes) {
if (index > -1) {
elCacheObj.sourcePgId = elCacheObj.sourcePgId || prevElCacheObj.sourcePgId
elCacheObj.renderPgId = elCacheObj.renderPgId || prevElCacheObj.renderPgId
elCacheObj.sourceInspector = elCacheObj.sourceInspector || prevElCacheObj.sourceInspector
if (elCacheObj.pgId && prevElCacheObj.pgId && elCacheObj.pgId !== prevElCacheObj.pgId) {
if (!prevElCacheNodes.map(prevElCacheNode => prevElCacheNode.pgId).includes(elCacheObj.pgId)) {
prevElCacheNodes.push(elCacheObj)
}
} else {
elCacheObj.pgId = elCacheObj.pgId || prevElCacheObj.pgId
prevElCacheNodes[index] = elCacheObj
}
} else {
prevElCacheNodes.push(elCacheObj)
}
pinegrow.elCache.set(el, prevElCacheNodes)
} else {
pinegrow.elCache.set(el, [elCacheObj])
childVNodes.forEach(childVNode => {
if (sourceFile) {
refreshVueSourceDomMapping(
hook,
pgId,
isRootFragment ? el : rootEl,
key,
localFile,
sourceFile
)(childVNode)
} else {
refreshVueSourceDomMapping(hook, pgId, isRootFragment ? el : rootEl, key)(childVNode)
}
})
}
if (pinegrow.elUpdateHanderFn) {
pinegrow.elUpdateHanderFn(el)
}
} catch (err) {
console.log(err)
if (pinegrow.elCacheErrHandlerFn) {
pinegrow.elCacheErrHandlerFn(vnode, hook, rootEl, pgId, key, el, instance, err.message)
}
}
}
const elUpdateHanderFn = el => {
// if (pinegrow.elCache.has(el)) {
// const { pgId } = pinegrow.elCache.get(el)
// if (pgId) {
// // console.log(`Reselect ${pgId}`)
// }
// }
}
const elCacheErrHandlerFn = () => {
if (message) {
// console.log(message)
}
}
const cleanupCache = () => {
// for (let [key, value] of pinegrow.elCache.entries()) {
// if (value.isFragment && !value.firstEl) {
// console.log(value)
// }
// }
for (let [el, elCacheNodes] of pinegrow.elCache.entries()) {
// if (!el.isConnected) {
// pinegrow.elCache.delete(el)
// continue
// }
const cleanedUpElCacheNodes = elCacheNodes.filter(
elCacheObj => !elCacheObj.instance.isUnmounted // || elCacheObj.localFile
)
if (cleanedUpElCacheNodes.length) {
if (cleanedUpElCacheNodes.length !== elCacheNodes.length) {
pinegrow.elCache.set(el, cleanedUpElCacheNodes)
}
} else {
pinegrow.elCache.delete(el)
}
if (pinegrow.elUpdateHanderFn) {
pinegrow.elUpdateHanderFn(el)
}
}
}
// Local Component
const rootVNode = ref(null)
const mountLocalComponent = () => {
const instance = getCurrentInstance()
const vnode = instance?.vnode
const el = vnode?.el
const localFile = instance.type.__file && !instance.type.__file.includes('node_modules') && instance.type.__file
if (instance && vnode && el) {
rootVNode.value = vnode
refreshVueSourceDomMapping('mounted', null, null, null, localFile)(vnode)
}
}
const unmountLocalComponent = () => {
if (rootVNode.value) {
refreshVueSourceDomMapping('unmounted')(rootVNode.value)
}
cleanupCache()
}
onBeforeMount(() => ensurePinegrowVueRuntime())
onMounted(() => {
mountLocalComponent()
})
onBeforeUnmount(() => unmountLocalComponent())
onUpdated(() => {
mountLocalComponent()
})
return {
refreshVueSourceDomMapping,
pgUpdateElCache: refreshVueSourceDomMapping,
}
}
export function usePinegrow() {
return createVueRuntimeBridge()
}
export { createVueRuntimeBridge, usePinegrow } from './runtime.js'
/*! For license information please see runtime.cjs.LICENSE.txt */
(()=>{var e={748:e=>{e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n},e.exports.__esModule=!0,e.exports.default=e.exports},314:e=>{e.exports=function(e){if(Array.isArray(e))return e},e.exports.__esModule=!0,e.exports.default=e.exports},850:(e,t,r)=>{var n=r(748);e.exports=function(e){if(Array.isArray(e))return n(e)},e.exports.__esModule=!0,e.exports.default=e.exports},461:e=>{function t(e,t,r,n,o,l,i){try{var u=e[l](i),a=u.value}catch(e){return void r(e)}u.done?t(a):Promise.resolve(a).then(n,o)}e.exports=function(e){return function(){var r=this,n=arguments;return new Promise((function(o,l){var i=e.apply(r,n);function u(e){t(i,o,l,u,a,"next",e)}function a(e){t(i,o,l,u,a,"throw",e)}u(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},290:(e,t,r)=>{var n=r(739);e.exports=function(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports},912:e=>{e.exports=function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)},e.exports.__esModule=!0,e.exports.default=e.exports},193:e=>{e.exports=function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,l,i,u=[],a=!0,c=!1;try{if(l=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=l.call(r)).done)&&(u.push(n.value),u.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{if(!a&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return u}},e.exports.__esModule=!0,e.exports.default=e.exports},849:e=>{e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},96:e=>{e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports},609:(e,t,r)=>{var n=r(425).default;function o(){"use strict";e.exports=o=function(){return r},e.exports.__esModule=!0,e.exports.default=e.exports;var t,r={},l=Object.prototype,i=l.hasOwnProperty,u=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",d=a.toStringTag||"@@toStringTag";function f(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{f({},"")}catch(t){f=function(e,t,r){return e[t]=r}}function p(e,t,r,n){var o=t&&t.prototype instanceof b?t:b,l=Object.create(o.prototype),i=new M(n||[]);return u(l,"_invoke",{value:C(e,r,i)}),l}function v(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}r.wrap=p;var h="suspendedStart",y="suspendedYield",g="executing",m="completed",x={};function b(){}function w(){}function I(){}var _={};f(_,c,(function(){return this}));var E=Object.getPrototypeOf,P=E&&E(E(k([])));P&&P!==l&&i.call(P,c)&&(_=P);var F=I.prototype=b.prototype=Object.create(_);function S(e){["next","throw","return"].forEach((function(t){f(e,t,(function(e){return this._invoke(t,e)}))}))}function j(e,t){function r(o,l,u,a){var c=v(e[o],e,l);if("throw"!==c.type){var s=c.arg,d=s.value;return d&&"object"==n(d)&&i.call(d,"__await")?t.resolve(d.__await).then((function(e){r("next",e,u,a)}),(function(e){r("throw",e,u,a)})):t.resolve(d).then((function(e){s.value=e,u(s)}),(function(e){return r("throw",e,u,a)}))}a(c.arg)}var o;u(this,"_invoke",{value:function(e,n){function l(){return new t((function(t,o){r(e,n,t,o)}))}return o=o?o.then(l,l):l()}})}function C(e,r,n){var o=h;return function(l,i){if(o===g)throw new Error("Generator is already running");if(o===m){if("throw"===l)throw i;return{value:t,done:!0}}for(n.method=l,n.arg=i;;){var u=n.delegate;if(u){var a=O(u,n);if(a){if(a===x)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=g;var c=v(e,r,n);if("normal"===c.type){if(o=n.done?m:y,c.arg===x)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=m,n.method="throw",n.arg=c.arg)}}}function O(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,O(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),x;var l=v(o,e.iterator,r.arg);if("throw"===l.type)return r.method="throw",r.arg=l.arg,r.delegate=null,x;var i=l.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,x):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,x)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function M(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function k(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,l=function r(){for(;++o<e.length;)if(i.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return l.next=l}}throw new TypeError(n(e)+" is not iterable")}return w.prototype=I,u(F,"constructor",{value:I,configurable:!0}),u(I,"constructor",{value:w,configurable:!0}),w.displayName=f(I,d,"GeneratorFunction"),r.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===w||"GeneratorFunction"===(t.displayName||t.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,I):(e.__proto__=I,f(e,d,"GeneratorFunction")),e.prototype=Object.create(F),e},r.awrap=function(e){return{__await:e}},S(j.prototype),f(j.prototype,s,(function(){return this})),r.AsyncIterator=j,r.async=function(e,t,n,o,l){void 0===l&&(l=Promise);var i=new j(p(e,t,n,o),l);return r.isGeneratorFunction(t)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},S(F),f(F,d,"Generator"),f(F,c,(function(){return this})),f(F,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=k,M.prototype={constructor:M,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(A),!e)for(var r in this)"t"===r.charAt(0)&&i.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return u.type="throw",u.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var l=this.tryEntries[o],u=l.completion;if("root"===l.tryLoc)return n("end");if(l.tryLoc<=this.prev){var a=i.call(l,"catchLoc"),c=i.call(l,"finallyLoc");if(a&&c){if(this.prev<l.catchLoc)return n(l.catchLoc,!0);if(this.prev<l.finallyLoc)return n(l.finallyLoc)}else if(a){if(this.prev<l.catchLoc)return n(l.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<l.finallyLoc)return n(l.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var l=o?o.completion:{};return l.type=e,l.arg=t,o?(this.method="next",this.next=o.finallyLoc,x):this.complete(l)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),x},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),x}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;A(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:k(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),x}},r}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},681:(e,t,r)=>{var n=r(314),o=r(193),l=r(121),i=r(849);e.exports=function(e,t){return n(e)||o(e,t)||l(e,t)||i()},e.exports.__esModule=!0,e.exports.default=e.exports},408:(e,t,r)=>{var n=r(850),o=r(912),l=r(121),i=r(96);e.exports=function(e){return n(e)||o(e)||l(e)||i()},e.exports.__esModule=!0,e.exports.default=e.exports},64:(e,t,r)=>{var n=r(425).default;e.exports=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},739:(e,t,r)=>{var n=r(425).default,o=r(64);e.exports=function(e){var t=o(e,"string");return"symbol"===n(t)?t:String(t)},e.exports.__esModule=!0,e.exports.default=e.exports},425:e=>{function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},121:(e,t,r)=>{var n=r(748);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.__esModule=!0,e.exports.default=e.exports},841:(e,t,r)=>{var n=r(609)();e.exports=n;try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var l=t[n]={exports:{}};return e[n](l,l.exports,r),l.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";r.r(n),r.d(n,{createVueRuntimeBridge:()=>_,usePinegrow:()=>E});var e=r(681),t=r(408),o=r(461),l=r(841);const i=require("vue");var u=r(290);function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){u(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var d=function(e){return{get value(){return e()}}},f=function(e){return{value:e}},p=function(e,t){return(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).immediate&&"function"==typeof t&&t(function(e){return"function"==typeof e?e():null==e?void 0:e.value}(e),void 0),function(){}},v=function(e){return{pageTree:"source-node"===e,appTree:"component-boundary"===e||"page-root"===e}},h=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e.firstEl||e.el||t||null},y=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return e.lastEl||e.firstEl||e.el||t||null},g=function(e){var t,r,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,l=null===(t=e.vnode)||void 0===t?void 0:t.props,i=h(e,o);return e.sourceInspector||(null==l?void 0:l["data-v-inspector"])||(null==i||null===(r=i.getAttribute)||void 0===r?void 0:r.call(i,"data-v-inspector"))||(null==o||null===(n=o.getAttribute)||void 0===n?void 0:n.call(o,"data-v-inspector"))||null},m=function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:d)((function(){var r,n=new Map,o=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return s(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,i=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){u=!0,l=e},f:function(){try{i||null==r.return||r.return()}finally{if(u)throw l}}}}(t.entries());try{var l=function(){var o,l=e(r.value,2),i=l[0],u=l[1];(o=u,Array.isArray(o)?o:[]).forEach((function(e){var r,o,l,u,a;if(function(e){return!1!==e.instance.isMounted&&!0!==e.instance.isUnmounted}(e)&&function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=h(e,t),n=y(e,t);return Boolean((null==r?void 0:r.isConnected)||(null==n?void 0:n.isConnected)||(null==t?void 0:t.isConnected))}(e,i)&&!0===e.treeScopes.appTree&&e.localFile){var s=e.localFile,d=h(e,i),f=y(e,i);if(d){if(e.isIsland){var p=d.firstElementChild;if(p&&t.has(p))return}var v=null!==(r=e.sourcePgId)&&void 0!==r?r:null,m=v?null!==(u=e.renderPgId)&&void 0!==u?u:null:null!==(o=null!==(l=e.renderPgId)&&void 0!==l?l:e.pgId)&&void 0!==o?o:null,x=c(c({},e),{},{sourceElCacheObj:e,appTreeBoundary:!0,appTreeBoundaryId:null,localFile:s,firstEl:d,lastEl:f,sourcePgId:v,renderPgId:m,sourceInspector:g(e,i)}),b=[s||"",x.instance.uid,null!==(a=x.key)&&void 0!==a?a:""].join("::"),w=n.get(b),I=x;if(w){var _,E,P,F,S,j,C,O,T=x.sourcePgId&&!w.sourcePgId?x:w,A=T===w?x:w,M=T.sourcePgId?T.sourceElCacheObj||T:A.sourcePgId?A.sourceElCacheObj||A:T.sourceElCacheObj||A.sourceElCacheObj||T,k=null!==(_=null!==(E=T.sourcePgId)&&void 0!==E?E:A.sourcePgId)&&void 0!==_?_:null,L=null!==(P=null!==(F=T.renderPgId)&&void 0!==F?F:A.renderPgId)&&void 0!==P?P:null,B=null!==(S=null!==(j=T.sourceInspector)&&void 0!==j?j:A.sourceInspector)&&void 0!==S?S:null;I=c(c(c({},A),T),{},{sourceElCacheObj:M,sourcePgId:k,renderPgId:L,sourceInspector:B,pgId:null!==(C=null!==(O=null!=k?k:T.pgId)&&void 0!==O?O:A.pgId)&&void 0!==C?C:null,firstEl:T.firstEl||A.firstEl,lastEl:T.lastEl||A.lastEl,el:T.el||A.el,localFile:T.localFile||A.localFile})}n.set(b,I)}}}))};for(o.s();!(r=o.n()).done;)l()}catch(e){o.e(e)}finally{o.f()}return Array.from(n.values()).map((function(e){var t,r,n,o,l,i,u,a,s=[(t=e).localFile||"",null!==(r=t.instance.uid)&&void 0!==r?r:"",null!==(n=t.key)&&void 0!==n?n:"",null!==(o=null!==(l=null!==(i=null!==(u=t.sourcePgId)&&void 0!==u?u:t.pgId)&&void 0!==i?i:t.sourceId)&&void 0!==l?l:null===(a=t.source)||void 0===a?void 0:a.id)&&void 0!==o?o:""].join("::");return c(c({},e),{},{appTreeBoundaryId:s})})).sort((function(e,t){var r=h(e),n=h(t);if(null==r||!r.compareDocumentPosition||!n)return 0;var o=r.compareDocumentPosition(n);return 2&o?1:4&o?-1:0}))}))},x=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return null;e.pinegrow||(e.pinegrow={});var r,n=e.pinegrow,o=t.reactiveFromContext||n.reactiveFromContext||function(e){return e},l=t.refFromContext||n.refFromContext||f,i=t.computedFromContext||n.computedFromContext||d,u=t.watchFromContext||n.watchFromContext||p,a=o((r=n.elCache)&&"function"==typeof r.get&&"function"==typeof r.set&&"function"==typeof r.delete&&"function"==typeof r.entries?n.elCache:new Map);return n.elCache===a&&n.appTreeBoundariesComputed&&n.reactiveFromContext===o&&n.refFromContext===l&&n.computedFromContext===i&&n.watchFromContext===u||Object.assign(n,{elCache:a,appTreeBoundariesComputed:m(a,i),reactiveFromContext:o,refFromContext:l,computedFromContext:i,watchFromContext:u}),n},b=function(e){var t,r,n,o,l,i,u,a,s,d,f,p,h,y,g,m,x,b,w,I,_,E,P,F,S,j,C=null!==(t=e.sourceRange)&&void 0!==t?t:null,O=e.entryKind;return c({el:e.el,framework:e.framework,entryKind:O,treeScopes:e.treeScopes||v(O),isRootFragment:Boolean(e.isRootFragment),rootEl:null!==(r=e.rootEl)&&void 0!==r?r:null,vnode:null!==(n=e.vnode)&&void 0!==n?n:null,instance:e.instance,isFragment:Boolean(e.isFragment),firstEl:null!==(o=e.firstEl)&&void 0!==o?o:null,lastEl:null!==(l=e.lastEl)&&void 0!==l?l:null,pgId:null!==(i=e.pgId)&&void 0!==i?i:null,sourceId:null!==(u=e.sourceId)&&void 0!==u?u:null,sourcePgId:null!==(a=e.sourcePgId)&&void 0!==a?a:null,renderPgId:null!==(s=e.renderPgId)&&void 0!==s?s:null,sourceInspector:null!==(d=e.sourceInspector)&&void 0!==d?d:null,sourceFile:null!==(f=e.sourceFile)&&void 0!==f?f:null,key:null!==(p=e.key)&&void 0!==p?p:null,localFile:null!==(h=e.localFile)&&void 0!==h?h:null,name:null!==(y=e.name)&&void 0!==y?y:"",source:null!==(g=e.source)&&void 0!==g?g:null,component:null!==(m=e.component)&&void 0!==m?m:null,owners:null!==(x=e.owners)&&void 0!==x?x:[],sourceRange:C,sourceStart:null!==(b=null!==(w=e.sourceStart)&&void 0!==w?w:null==C?void 0:C.start)&&void 0!==b?b:null,sourceEnd:null!==(I=null!==(_=e.sourceEnd)&&void 0!==_?_:null==C?void 0:C.end)&&void 0!==I?I:null,sourceRangeStatus:null!==(E=null!==(P=e.sourceRangeStatus)&&void 0!==P?P:null==C?void 0:C.status)&&void 0!==E?E:null,marker:null!==(F=e.marker)&&void 0!==F?F:null,editability:null!==(S=e.editability)&&void 0!==S?S:null,attributes:null!==(j=e.attributes)&&void 0!==j?j:[],state:e.state,isIsland:Boolean(e.isIsland)},e.extra||{})};function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var I=function(e,t){return e?"source-node":t?"component-boundary":"render-node"};function _(){var r=function(){var e,t=window;null!=t&&null!==(e=t.process)&&void 0!==e&&e.client&&!0!==t.process.client||x(t,{reactiveFromContext:i.reactive,refFromContext:i.ref,computedFromContext:i.computed,watchFromContext:i.watch})},n=function e(n,i,u,a,c,s){var d;return function(f){return(d=d||o(l.mark((function o(d){var f,p,h,y,m,x,w,_,E,P,F,S,j,C,O,T,A,M,k,L,B,U,R,N,G,D,H;return l.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(d){o.next=2;break}return o.abrupt("return");case 2:if(null===(f=window)||void 0===f||null===(f=f.process)||void 0===f||!f.client||!0===(null===(p=process)||void 0===p?void 0:p.client)){o.next=4;break}return o.abrupt("return");case 4:if(window.pinegrow||r(),h=d.el,y=d.component||d.ctx||h.__vueParentComponent,h&&y){o.next=9;break}return o.abrupt("return");case 9:if(o.prev=9,(null!=a||null!==d.key&&void 0!==d.key)&&(a=d.key||a),s||(c=c||d.type.__file),x=!1,w=1!==h.nodeType,P=!1,F=[],c&&(c.includes("node_modules/iles")&&c.includes("Island.vue")&&(P=!0),c.includes("node_modules")&&(c=null)),(S=y.type.__file)&&S.includes("node_modules/iles")&&S.includes("Island.vue")&&(P=!0,c=(null===(j=y.props.component)||void 0===j?void 0:j.__file)||y.props.importFrom),w&&(C=function(e){return 1!==e.subTree.el.nodeType},O=function(e){return C(e)?T(e.subTree):e.subTree?[e.subTree]:[]},T=function(e){if(!e.children)return[];if(!Array.isArray(e.children))return[];for(var r=[],n=0,o=e.children.length;n<o;n++){var l=e.children[n];l.component?r.push.apply(r,t(O(l.component))):l&&r.push(l)}return r},u||(x=!0),(F=O(y)).length||h.nextElementSibling&&(A=h.nextElementSibling,_=E=A,M=A.$||A.__vueParentComponent,(k=null==M?void 0:M.vnode)&&F.push(k)),F.length&&(F=F.filter((function(e){return e.el!==h})),F.length&&(1===F.length?_=E=F[0].el:(_=F[0].el,E=F[F.length-1].el),_&&1!==_.nodeType&&(_=_.nextElementSibling),E&&1!==E.nodeType&&(E=E.nextElementSibling)))),!P||x){o.next=21;break}return o.abrupt("return");case 21:L=Boolean(d.component),B=g({vnode:d,el:h,firstEl:_,lastEl:E},h),U=Boolean(s&&i),R=pinegrow.elCache.get(h),N=null,G=-1,R&&(G=U?R.findIndex((function(e){return e.instance.uid===y.uid&&e.sourceFile===s&&e.pgId===i})):R.findIndex((function(e){return e.instance.uid===y.uid})),G>-1&&(N=R[G],s||(c=c||N.localFile))),c=null!==(m=c)&&void 0!==m?m:null,D=I(U,c),H=b({el:h,isRootFragment:x,rootEl:u,vnode:d,instance:y,isFragment:w,firstEl:_,lastEl:E,pgId:i,sourcePgId:!s&&L&&i?i:null,renderPgId:s||L||!i?null:i,sourceInspector:B,sourceFile:U?s:null,framework:"vue",entryKind:D,treeScopes:v(D),key:a,localFile:c,isIsland:P}),R?(G>-1?(H.sourcePgId=H.sourcePgId||N.sourcePgId,H.renderPgId=H.renderPgId||N.renderPgId,H.sourceInspector=H.sourceInspector||N.sourceInspector,H.pgId&&N.pgId&&H.pgId!==N.pgId?R.map((function(e){return e.pgId})).includes(H.pgId)||R.push(H):(H.pgId=H.pgId||N.pgId,R[G]=H)):R.push(H),pinegrow.elCache.set(h,R)):(pinegrow.elCache.set(h,[H]),F.forEach((function(t){s?e(n,i,x?h:u,a,c,s)(t):e(n,i,x?h:u,a)(t)}))),pinegrow.elUpdateHanderFn&&pinegrow.elUpdateHanderFn(h),o.next=39;break;case 35:o.prev=35,o.t0=o.catch(9),console.log(o.t0),pinegrow.elCacheErrHandlerFn&&pinegrow.elCacheErrHandlerFn(d,n,u,i,a,h,y,o.t0.message);case 39:case"end":return o.stop()}}),o,null,[[9,35]])})))).apply(this,arguments)}},u=(0,i.ref)(null),a=function(){var e=(0,i.getCurrentInstance)(),t=null==e?void 0:e.vnode,r=null==t?void 0:t.el,o=e.type.__file&&!e.type.__file.includes("node_modules")&&e.type.__file;e&&t&&r&&(u.value=t,n("mounted",null,null,null,o)(t))},c=function(){u.value&&n("unmounted")(u.value),function(){var t,r=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return w(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?w(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,i=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){u=!0,l=e},f:function(){try{i||null==r.return||r.return()}finally{if(u)throw l}}}}(pinegrow.elCache.entries());try{for(r.s();!(t=r.n()).done;){var n=e(t.value,2),o=n[0],l=n[1],i=l.filter((function(e){return!e.instance.isUnmounted}));i.length?i.length!==l.length&&pinegrow.elCache.set(o,i):pinegrow.elCache.delete(o),pinegrow.elUpdateHanderFn&&pinegrow.elUpdateHanderFn(o)}}catch(e){r.e(e)}finally{r.f()}}()};return(0,i.onBeforeMount)((function(){return r()})),(0,i.onMounted)((function(){a()})),(0,i.onBeforeUnmount)((function(){return c()})),(0,i.onUpdated)((function(){a()})),{refreshVueSourceDomMapping:n,pgUpdateElCache:n}}function E(){return _()}})(),module.exports=n})();
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
export type VueSourceDomMappingRefresher = (
hook?: string,
pgId?: string | number | null,
rootEl?: Element | null,
key?: string | number | null,
localFile?: string | null,
sourceFile?: string | null
) => (vnode: unknown) => Promise<void>
export function createVueRuntimeBridge(): {
refreshVueSourceDomMapping: VueSourceDomMappingRefresher
pgUpdateElCache: VueSourceDomMappingRefresher
}
export function usePinegrow(): {
refreshVueSourceDomMapping: VueSourceDomMappingRefresher
pgUpdateElCache: VueSourceDomMappingRefresher
}
+19
-3
{
"name": "@pinegrow/vite-plugin",
"version": "3.0.77-alpha.0",
"version": "3.0.77-beta.0",
"description": "Pinegrow Vite Plugin",

@@ -8,3 +8,4 @@ "type": "module",

"dist",
"./types.d.ts"
"./types.d.ts",
"./vue-runtime.d.ts"
],

@@ -24,4 +25,19 @@ "main": "./dist/index.cjs",

},
"./dev/vue/runtime": {
"import": "./src/adapters/vue-sfc/mapping/runtime/runtime.js",
"require": "./src/adapters/vue-sfc/mapping/runtime/runtime.js"
},
"./dev/vue": {
"import": "./src/adapters/vue-sfc/mapping/runtime/runtime.js",
"require": "./src/adapters/vue-sfc/mapping/runtime/runtime.js"
},
"./vue/runtime": {
"types": "./vue-runtime.d.ts",
"import": "./dist/adapters/vue-sfc/mapping/runtime/runtime.mjs",
"require": "./dist/vue/runtime.cjs"
},
"./vue": {
"import": "./dist/runtime/vue/runtime-adapter.js"
"types": "./vue-runtime.d.ts",
"import": "./dist/adapters/vue-sfc/mapping/runtime/runtime.mjs",
"require": "./dist/vue/runtime.cjs"
}

@@ -28,0 +44,0 @@ },

-547
import {
onBeforeMount,
onMounted,
onBeforeUnmount,
getCurrentInstance,
ref,
reactive,
onUpdated,
computed,
watch,
} from 'vue'
const getVueCacheEntryKind = (isSourceNode, localFile) => {
if (isSourceNode) {
return 'source-node'
}
return localFile ? 'component-boundary' : 'render-node'
}
const getVueCacheTreeScopes = entryKind => ({
pageTree: entryKind === 'source-node',
appTree: entryKind === 'component-boundary',
})
const getBoundaryElement = (elCacheObj, fallbackEl = null) =>
elCacheObj.firstEl || elCacheObj.el || fallbackEl || null
const getBoundaryLastElement = (elCacheObj, fallbackEl = null) =>
elCacheObj.lastEl || elCacheObj.firstEl || elCacheObj.el || fallbackEl || null
const getSourceInspector = (elCacheObj, fallbackEl = null) => {
const props = elCacheObj.vnode?.props
const firstEl = getBoundaryElement(elCacheObj, fallbackEl)
return (
elCacheObj.sourceInspector ||
props?.['data-v-inspector'] ||
firstEl?.getAttribute?.('data-v-inspector') ||
fallbackEl?.getAttribute?.('data-v-inspector') ||
null
)
}
const isBoundaryConnected = (elCacheObj, fallbackEl = null) => {
const firstEl = getBoundaryElement(elCacheObj, fallbackEl)
const lastEl = getBoundaryLastElement(elCacheObj, fallbackEl)
return Boolean(firstEl?.isConnected || lastEl?.isConnected || fallbackEl?.isConnected)
}
const isBoundaryMounted = elCacheObj => {
return elCacheObj.instance.isMounted !== false && elCacheObj.instance.isUnmounted !== true
}
const getBoundaryId = elCacheObj => {
const file = elCacheObj.localFile || ''
const uid = elCacheObj.instance.uid ?? ''
const key = elCacheObj.key ?? ''
const pgId = elCacheObj.sourcePgId ?? elCacheObj.pgId ?? elCacheObj.sourceId ?? elCacheObj.source?.id ?? ''
return [file, uid, key, pgId].join('::')
}
const createAppTreeBoundariesComputed = elCache =>
computed(() => {
const boundariesByRuntimeKey = new Map()
for (let [el, elCacheNodes] of elCache.entries()) {
elCacheNodes.forEach(elCacheObj => {
if (
!isBoundaryMounted(elCacheObj) ||
!isBoundaryConnected(elCacheObj, el) ||
elCacheObj.treeScopes.appTree !== true ||
!elCacheObj.localFile
) {
return
}
const localFile = elCacheObj.localFile
const firstEl = getBoundaryElement(elCacheObj, el)
const lastEl = getBoundaryLastElement(elCacheObj, el)
if (!firstEl) {
return
}
if (elCacheObj.isIsland) {
const childEl = firstEl.firstElementChild
if (childEl && elCache.has(childEl)) {
return
}
}
const sourcePgId = elCacheObj.sourcePgId ?? null
const renderPgId = !sourcePgId
? elCacheObj.renderPgId ?? elCacheObj.pgId ?? null
: elCacheObj.renderPgId ?? null
const candidate = {
...elCacheObj,
sourceElCacheObj: elCacheObj,
appTreeBoundary: true,
appTreeBoundaryId: null,
localFile,
firstEl,
lastEl,
sourcePgId,
renderPgId,
sourceInspector: getSourceInspector(elCacheObj, el),
}
// Start App Tree runtime-boundary dedupe.
const runtimeKey = [localFile || '', candidate.instance.uid, candidate.key ?? ''].join('::')
const existingBoundary = boundariesByRuntimeKey.get(runtimeKey)
let boundary = candidate
if (existingBoundary) {
const preferred =
candidate.sourcePgId && !existingBoundary.sourcePgId ? candidate : existingBoundary
const fallback = preferred === existingBoundary ? candidate : existingBoundary
const sourceElCacheObj = preferred.sourcePgId
? preferred.sourceElCacheObj || preferred
: fallback.sourcePgId
? fallback.sourceElCacheObj || fallback
: preferred.sourceElCacheObj || fallback.sourceElCacheObj || preferred
const sourcePgId = preferred.sourcePgId ?? fallback.sourcePgId ?? null
const renderPgId = preferred.renderPgId ?? fallback.renderPgId ?? null
const sourceInspector = preferred.sourceInspector ?? fallback.sourceInspector ?? null
boundary = {
...fallback,
...preferred,
sourceElCacheObj,
sourcePgId,
renderPgId,
sourceInspector,
pgId: sourcePgId ?? preferred.pgId ?? fallback.pgId ?? null,
firstEl: preferred.firstEl || fallback.firstEl,
lastEl: preferred.lastEl || fallback.lastEl,
el: preferred.el || fallback.el,
localFile: preferred.localFile || fallback.localFile,
}
}
boundariesByRuntimeKey.set(runtimeKey, boundary)
// End App Tree runtime-boundary dedupe.
})
}
const boundaries = Array.from(boundariesByRuntimeKey.values()).map(boundary => {
const boundaryId = getBoundaryId(boundary)
return {
...boundary,
appTreeBoundaryId: boundaryId,
}
})
return boundaries.sort((a, b) => {
const aEl = getBoundaryElement(a)
const bEl = getBoundaryElement(b)
if (!aEl?.compareDocumentPosition || !bEl) {
return 0
}
const position = aEl.compareDocumentPosition(bEl)
if (position & Node.DOCUMENT_POSITION_PRECEDING) {
return 1
}
if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
return -1
}
return 0
})
})
export function usePinegrow() {
const initCache = () => {
// conditional
const winObj = window
if (!(winObj?.process?.client && winObj.process.client !== true)) {
const isMapLike = value =>
value &&
typeof value.get === 'function' &&
typeof value.set === 'function' &&
typeof value.delete === 'function' &&
typeof value.entries === 'function'
const existingPinegrow = winObj.pinegrow || {}
const existingElCache = isMapLike(existingPinegrow.elCache) ? existingPinegrow.elCache : new Map()
const elCache = reactive(existingElCache)
if (
!winObj.pinegrow ||
winObj.pinegrow.elCache !== elCache ||
!winObj.pinegrow.appTreeBoundariesComputed ||
winObj.pinegrow.reactiveFromContext !== reactive ||
winObj.pinegrow.refFromContext !== ref ||
winObj.pinegrow.computedFromContext !== computed ||
winObj.pinegrow.watchFromContext !== watch
) {
// console.log('Cache initialized by Vue Plugin!')
const enrichWithComponentName = (elCacheObj, localFile) => {
return {
name: elCacheObj.instance.type.__name || '',
localFile,
...elCacheObj,
}
}
winObj.pinegrow = Object.assign(existingPinegrow, {
elCache,
// pgIdToElComputed,
// localComponentToElComputed,
appTreeBoundariesComputed: createAppTreeBoundariesComputed(elCache),
reactiveFromContext: reactive,
refFromContext: ref,
computedFromContext: computed,
watchFromContext: watch,
// // Uncomment these two to test locally
// elCacheErrHandlerFn,
// elUpdateHanderFn,
})
}
}
}
// pgId & key can be optional
const pgUpdateElCache = (hook, pgId, rootEl, key, localFile, sourceFile) => async vnode => {
if (!vnode) return
if (window?.process?.client && process?.client !== true) return
if (!window.pinegrow) initCache()
let el = vnode.el
const instance = vnode.component || vnode.ctx || el.__vueParentComponent
if (!el || !instance) return
try {
if ((key !== null && key !== undefined) || (vnode.key !== null && vnode.key !== undefined)) {
key = vnode.key || key
}
if (!sourceFile) {
localFile = localFile || vnode.type.__file
}
let isRootFragment = false
let isFragment = el.nodeType !== 1
let firstEl,
lastEl,
isIsland = false,
childVNodes = []
// May be an iles Island that wraps components with client directives
if (localFile) {
if (localFile.includes('node_modules/iles') && localFile.includes('Island.vue')) {
// Retain localFiles of iles island to apply to child elements
isIsland = true
}
if (localFile.includes('node_modules')) {
// Ignore SFCs from node_modules
localFile = null
}
}
const localFileFromInstance = instance.type.__file
if (
localFileFromInstance &&
localFileFromInstance.includes('node_modules/iles') &&
localFileFromInstance.includes('Island.vue')
) {
// Retain localFiles of iles island to apply to child elements
isIsland = true
localFile = instance.props.component?.__file || instance.props.importFrom
}
// // Computed props anyway filters out unmounted ones, and we use the local components unmounted hooks to cleanup unmounted nodes. Using the unmounted hook seems to be out of sync when el is reused but instance is remounted.
// if (hook === 'unmounted') {
// if (pinegrow.elCache.has(el)) {
// pinegrow.elCache.delete(el)
// }
// for (let [key, value] of pinegrow.elCache.entries()) {
// if (value.rootEl === rootEl) {
// pinegrow.elCache.delete(key)
// }
// }
// return
// }
// Text/comment node
if (isFragment) {
if (!rootEl) {
// root Fragment
isRootFragment = true
}
function isFragmentEl(instance) {
// return appRecord.options.types.Fragment === instance.subTree?.type
return instance.subTree.el.nodeType !== 1
}
function getRootVNodesFromComponentInstance(instance) {
if (isFragmentEl(instance)) {
return getFragmentRootVNodes(instance.subTree)
}
if (!instance.subTree) return []
return [instance.subTree]
}
function getFragmentRootVNodes(vnode) {
if (!vnode.children) return []
// children is v-if when the vnode has a condition
if (!Array.isArray(vnode.children)) return []
const list = []
for (let i = 0, l = vnode.children.length; i < l; i++) {
const childVnode = vnode.children[i]
if (childVnode.component) {
list.push(...getRootVNodesFromComponentInstance(childVnode.component))
} else if (childVnode) {
list.push(childVnode)
}
}
return list
}
childVNodes = getRootVNodesFromComponentInstance(instance)
if (!childVNodes.length) {
// For NuxtLayout, no childVNodes are returned, the subTree.children is in fact an object {ctx: {}, default: f}
if (el.nextElementSibling) {
const childEl = el.nextElementSibling
firstEl = lastEl = childEl
const childInstance = childEl.$ || childEl.__vueParentComponent
const childVNode = childInstance?.vnode // or subTree?
if (childVNode) {
childVNodes.push(childVNode)
}
}
}
if (childVNodes.length) {
// Filter out recursive vnodes text1 -> div, text1 (happens when text1 is the closest to a fragment with div & slot)
childVNodes = childVNodes.filter(childVNode => childVNode.el !== el)
if (childVNodes.length) {
if (childVNodes.length === 1) {
firstEl = lastEl = childVNodes[0].el
} else {
firstEl = childVNodes[0].el
lastEl = childVNodes[childVNodes.length - 1].el
}
if (firstEl && firstEl.nodeType !== 1) {
firstEl = firstEl.nextElementSibling
}
if (lastEl && lastEl.nodeType !== 1) {
lastEl = lastEl.nextElementSibling
}
}
}
}
if (isIsland && !isRootFragment) {
return
}
const isComponentVNode = Boolean(vnode.component)
const sourceInspector = getSourceInspector({ vnode, el, firstEl, lastEl }, el)
const isSourceNode = Boolean(sourceFile && pgId)
let prevElCacheNodes = pinegrow.elCache.get(el)
let prevElCacheObj = null
let index = -1
if (prevElCacheNodes) {
index = isSourceNode
? prevElCacheNodes.findIndex(
prevElCacheObj =>
prevElCacheObj.instance.uid === instance.uid &&
prevElCacheObj.sourceFile === sourceFile &&
prevElCacheObj.pgId === pgId
)
: prevElCacheNodes.findIndex(elCacheObj => elCacheObj.instance.uid === instance.uid)
if (index > -1) {
prevElCacheObj = prevElCacheNodes[index]
if (!sourceFile) {
localFile = localFile || prevElCacheObj.localFile
}
}
}
localFile = localFile ?? null
const entryKind = getVueCacheEntryKind(isSourceNode, localFile)
let elCacheObj = {
el,
isRootFragment,
rootEl,
vnode,
instance,
isFragment,
firstEl,
lastEl,
pgId,
sourcePgId: !sourceFile && isComponentVNode && pgId ? pgId : null,
renderPgId: !sourceFile && !isComponentVNode && pgId ? pgId : null,
sourceInspector,
sourceFile: isSourceNode ? sourceFile : null,
framework: 'vue',
entryKind,
treeScopes: getVueCacheTreeScopes(entryKind),
key,
localFile,
isIsland,
}
if (prevElCacheNodes) {
if (index > -1) {
elCacheObj.sourcePgId = elCacheObj.sourcePgId || prevElCacheObj.sourcePgId
elCacheObj.renderPgId = elCacheObj.renderPgId || prevElCacheObj.renderPgId
elCacheObj.sourceInspector = elCacheObj.sourceInspector || prevElCacheObj.sourceInspector
if (elCacheObj.pgId && prevElCacheObj.pgId && elCacheObj.pgId !== prevElCacheObj.pgId) {
if (!prevElCacheNodes.map(prevElCacheNode => prevElCacheNode.pgId).includes(elCacheObj.pgId)) {
prevElCacheNodes.push(elCacheObj)
}
} else {
elCacheObj.pgId = elCacheObj.pgId || prevElCacheObj.pgId
prevElCacheNodes[index] = elCacheObj
}
} else {
prevElCacheNodes.push(elCacheObj)
}
pinegrow.elCache.set(el, prevElCacheNodes)
} else {
pinegrow.elCache.set(el, [elCacheObj])
childVNodes.forEach(childVNode => {
if (sourceFile) {
pgUpdateElCache(
hook,
pgId,
isRootFragment ? el : rootEl,
key,
localFile,
sourceFile
)(childVNode)
} else {
pgUpdateElCache(hook, pgId, isRootFragment ? el : rootEl, key)(childVNode)
}
})
}
if (pinegrow.elUpdateHanderFn) {
pinegrow.elUpdateHanderFn(el)
}
} catch (err) {
console.log(err)
if (pinegrow.elCacheErrHandlerFn) {
pinegrow.elCacheErrHandlerFn(vnode, hook, rootEl, pgId, key, el, instance, err.message)
}
}
}
const elUpdateHanderFn = el => {
// if (pinegrow.elCache.has(el)) {
// const { pgId } = pinegrow.elCache.get(el)
// if (pgId) {
// // console.log(`Reselect ${pgId}`)
// }
// }
}
const elCacheErrHandlerFn = () => {
if (message) {
// console.log(message)
}
}
const cleanupCache = () => {
// for (let [key, value] of pinegrow.elCache.entries()) {
// if (value.isFragment && !value.firstEl) {
// console.log(value)
// }
// }
for (let [el, elCacheNodes] of pinegrow.elCache.entries()) {
// if (!el.isConnected) {
// pinegrow.elCache.delete(el)
// continue
// }
const cleanedUpElCacheNodes = elCacheNodes.filter(
elCacheObj => !elCacheObj.instance.isUnmounted // || elCacheObj.localFile
)
if (cleanedUpElCacheNodes.length) {
if (cleanedUpElCacheNodes.length !== elCacheNodes.length) {
pinegrow.elCache.set(el, cleanedUpElCacheNodes)
}
} else {
pinegrow.elCache.delete(el)
}
if (pinegrow.elUpdateHanderFn) {
pinegrow.elUpdateHanderFn(el)
}
}
}
// Local Component
const rootVNode = ref(null)
const mountLocalComponent = () => {
const instance = getCurrentInstance()
const vnode = instance?.vnode
const el = vnode?.el
const localFile = instance.type.__file && !instance.type.__file.includes('node_modules') && instance.type.__file
if (instance && vnode && el) {
rootVNode.value = vnode
pgUpdateElCache('mounted', null, null, null, localFile)(vnode)
}
}
const unmountLocalComponent = () => {
if (rootVNode.value) {
pgUpdateElCache('unmounted')(rootVNode.value)
}
cleanupCache()
}
onBeforeMount(() => initCache())
onMounted(() => {
mountLocalComponent()
})
onBeforeUnmount(() => unmountLocalComponent())
onUpdated(() => {
mountLocalComponent()
})
return { pgUpdateElCache }
}

Sorry, the diff of this file is too big to display