@pinegrow/vite-plugin 3.0.73-alpha.1 → 3.0.73-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,14 +8,44 @@ export interface AstroRuntimeBridgeOptions {
8
8
  export interface AstroElCacheEntry {
9
9
  el: Element
10
10
  framework: 'astro'
11
+ entryKind: 'source-node' | 'component-boundary' | 'page-root'
12
+ treeScopes: {
13
+ pageTree: boolean
14
+ appTree: boolean
15
+ }
11
16
  isAstro: true
17
+ isAstroSourceDomEntry: boolean
18
+ isAstroComponent: boolean
19
+ isAppTreeComponent: boolean
20
+ isAstroPageRoot?: boolean
12
21
  sourceId: string
13
- pgId: string
14
- key: string
22
+ pgId: string | null
23
+ key: string | null
15
24
  localFile: string | null
16
25
  sourceFile: string | null
17
26
  nodeType: string | null
18
27
  name: string
28
+ source: {
29
+ id: string
30
+ file: string | null
31
+ range: {
32
+ start: number | null
33
+ end: number | null
34
+ status: string
35
+ }
36
+ nodeType: string | null
37
+ name: string
38
+ }
39
+ component: {
40
+ file: string
41
+ name: string
42
+ kind: string
43
+ } | null
44
+ owners: Array<{
45
+ kind: string
46
+ file: string
47
+ name?: string
48
+ }>
19
49
  sourceRange: {
20
50
  start: number | null
21
51
  end: number | null
@@ -32,11 +62,53 @@ export interface AstroElCacheEntry {
32
62
  isIsland: false
33
63
  rootEl: null
34
64
  firstEl: Element
35
- lastEl: Element
36
- instance: null
65
+ lastEl: Element | null
66
+ instance: {
67
+ uid: string
68
+ isMounted: boolean
69
+ isUnmounted: boolean
70
+ type: {
71
+ __name?: string
72
+ __file?: string | null
73
+ }
74
+ props: Record<string, unknown>
75
+ attrs: Record<string, unknown>
76
+ slots: Record<string, unknown>
77
+ subTree: {
78
+ el: Element
79
+ }
80
+ appContext: unknown
81
+ }
37
82
  vnode: null
38
83
  }
39
84
 
85
+ export type AstroComponentEntry = AstroElCacheEntry & {
86
+ entryKind: 'component-boundary' | 'page-root'
87
+ treeScopes: {
88
+ pageTree: false
89
+ appTree: true
90
+ }
91
+ isAstroSourceDomEntry: false
92
+ isAstroComponent: true
93
+ isAppTreeComponent: true
94
+ pgId: null
95
+ key: null
96
+ localFile: string
97
+ sourceFile: string
98
+ nodeType: 'component-file'
99
+ component: {
100
+ file: string
101
+ name: string
102
+ kind: string
103
+ }
104
+ }
105
+
106
+ export function createAstroComponentEntries(input: {
107
+ entries: AstroElCacheEntry[]
108
+ manifest: unknown
109
+ root?: Document | Element
110
+ }): AstroComponentEntry[]
111
+
40
112
  export function createAstroElCacheEntry(input: {
41
113
  element: Element
42
114
  manifest: unknown
@@ -25,13 +25,20 @@ const createFallbackWatch = (source, callback, options = {}) => {
25
25
  return () => {}
26
26
  }
27
27
 
28
- const createAstroSyntheticInstance = (manifest, node) => ({
28
+ const createAstroSyntheticInstance = (node, element) => ({
29
29
  uid: `astro:${node.id}`,
30
30
  isMounted: true,
31
31
  isUnmounted: false,
32
+ parent: null,
32
33
  type: {
33
34
  __name: node.name || 'AstroElement',
34
- __file: manifest.sourceFile || null,
35
+ __file: null,
36
+ },
37
+ props: {},
38
+ attrs: {},
39
+ slots: {},
40
+ subTree: {
41
+ el: element,
35
42
  },
36
43
  appContext: null,
37
44
  })
@@ -51,6 +58,13 @@ const isMapLike = value =>
51
58
  typeof value.delete === 'function' &&
52
59
  typeof value.entries === 'function'
53
60
 
61
+ const createReactiveMap = (pinegrow, value) => {
62
+ const map = isMapLike(value) ? value : new Map()
63
+ const reactiveFromContext = pinegrow?.reactiveFromContext
64
+
65
+ return typeof reactiveFromContext === 'function' ? reactiveFromContext(map) : map
66
+ }
67
+
54
68
  const getMarkerAttribute = (manifest, options = {}) =>
55
69
  options.markerAttribute || manifest?.marker?.attribute || defaultMarkerAttribute
56
70
 
@@ -58,6 +72,57 @@ const getManifestSourceKey = manifest => manifest?.sourceFile || manifest?.id ||
58
72
 
59
73
  const normalizeElCacheEntries = entries => Array.isArray(entries) ? entries : []
60
74
 
75
+ const normalizePathLike = value => `${value || ''}`.replace(/\\/g, '/')
76
+
77
+ const getBasename = value => {
78
+ if (!value) {
79
+ return ''
80
+ }
81
+
82
+ return normalizePathLike(value).split('/').pop() || ''
83
+ }
84
+
85
+ const isAstroPageSourceFile = sourceFile =>
86
+ /(^|\/)src\/pages\/.+\.astro$/i.test(normalizePathLike(sourceFile))
87
+
88
+ const getRootElement = root => {
89
+ if (!root) {
90
+ return null
91
+ }
92
+
93
+ if (root.documentElement) {
94
+ return root.documentElement
95
+ }
96
+
97
+ if (root.body) {
98
+ return root.body
99
+ }
100
+
101
+ if (root.firstElementChild) {
102
+ return root.firstElementChild
103
+ }
104
+
105
+ return root.nodeType === 1 ? root : null
106
+ }
107
+
108
+ const createAstroComponentSyntheticInstance = (manifest, componentId, element) => ({
109
+ uid: componentId,
110
+ isMounted: true,
111
+ isUnmounted: false,
112
+ parent: null,
113
+ type: {
114
+ __name: getBasename(manifest?.sourceFile) || 'AstroComponent',
115
+ __file: manifest?.sourceFile || null,
116
+ },
117
+ props: {},
118
+ attrs: {},
119
+ slots: {},
120
+ subTree: {
121
+ el: element,
122
+ },
123
+ appContext: null,
124
+ })
125
+
61
126
  const createNodeIndex = manifest => {
62
127
  const index = new Map()
63
128
 
@@ -96,14 +161,31 @@ const createAstroElCacheEntry = ({ element, manifest, node }) => {
96
161
  return {
97
162
  el: element,
98
163
  framework: astroFrameworkKey,
164
+ entryKind: 'source-node',
165
+ treeScopes: {
166
+ pageTree: true,
167
+ appTree: false,
168
+ },
99
169
  isAstro: true,
170
+ isAstroSourceDomEntry: true,
171
+ isAstroComponent: false,
172
+ isAppTreeComponent: false,
100
173
  sourceId: node.id,
101
174
  pgId: node.id,
102
175
  key: node.id,
103
- localFile: manifest.sourceFile || null,
176
+ localFile: null,
104
177
  sourceFile: manifest.sourceFile || null,
105
178
  nodeType: node.type || null,
106
179
  name: node.name || '',
180
+ source: {
181
+ id: node.id,
182
+ file: manifest.sourceFile || null,
183
+ range: sourceRange,
184
+ nodeType: node.type || null,
185
+ name: node.name || '',
186
+ },
187
+ component: null,
188
+ owners: [],
107
189
  sourceRange,
108
190
  sourceStart: sourceRange.start,
109
191
  sourceEnd: sourceRange.end,
@@ -117,11 +199,98 @@ const createAstroElCacheEntry = ({ element, manifest, node }) => {
117
199
  rootEl: null,
118
200
  firstEl: element,
119
201
  lastEl: element,
120
- instance: createAstroSyntheticInstance(manifest, node),
202
+ instance: createAstroSyntheticInstance(node, element),
121
203
  vnode: null,
122
204
  }
123
205
  }
124
206
 
207
+ const createAstroComponentEntry = ({ entries, manifest, root }) => {
208
+ const sourceFile = manifest?.sourceFile
209
+ const rootElement = getRootElement(root)
210
+ const isPageFile = isAstroPageSourceFile(sourceFile)
211
+ const isPageRoot = isPageFile && rootElement
212
+
213
+ if (!sourceFile || (!entries.length && !isPageRoot)) {
214
+ return null
215
+ }
216
+
217
+ const firstEntry = entries[0]
218
+ const lastEntry = entries[entries.length - 1]
219
+ const componentId = `astro-component:${sourceFile}`
220
+ const firstEl = isPageRoot ? rootElement : firstEntry.firstEl || firstEntry.el
221
+ const lastEl = isPageRoot ? null : lastEntry.lastEl || lastEntry.el
222
+ const componentName = getBasename(sourceFile)
223
+ const entryKind = isPageRoot ? 'page-root' : 'component-boundary'
224
+
225
+ return {
226
+ el: firstEl,
227
+ framework: astroFrameworkKey,
228
+ entryKind,
229
+ treeScopes: {
230
+ pageTree: false,
231
+ appTree: true,
232
+ },
233
+ isAstro: true,
234
+ isAstroSourceDomEntry: false,
235
+ isAstroComponent: true,
236
+ isAppTreeComponent: true,
237
+ isAstroPageRoot: Boolean(isPageRoot),
238
+ sourceId: componentId,
239
+ pgId: null,
240
+ key: null,
241
+ localFile: sourceFile,
242
+ sourceFile,
243
+ nodeType: 'component-file',
244
+ name: componentName,
245
+ source: {
246
+ id: componentId,
247
+ file: sourceFile,
248
+ range: {
249
+ start: null,
250
+ end: null,
251
+ status: 'component-file',
252
+ },
253
+ nodeType: 'component-file',
254
+ name: componentName,
255
+ },
256
+ component: {
257
+ file: sourceFile,
258
+ name: componentName,
259
+ kind: isPageFile ? 'page' : 'component',
260
+ },
261
+ owners: [],
262
+ sourceRange: {
263
+ start: null,
264
+ end: null,
265
+ status: 'component-file',
266
+ },
267
+ sourceStart: null,
268
+ sourceEnd: null,
269
+ sourceRangeStatus: 'component-file',
270
+ marker: null,
271
+ editability: {
272
+ mode: 'inspect',
273
+ operations: ['select', 'open-source-file'],
274
+ reasons: ['astro-component-file'],
275
+ },
276
+ attributes: [],
277
+ isFragment: false,
278
+ isRootFragment: false,
279
+ isIsland: false,
280
+ rootEl: null,
281
+ firstEl,
282
+ lastEl,
283
+ instance: createAstroComponentSyntheticInstance(manifest, componentId, firstEl),
284
+ vnode: null,
285
+ }
286
+ }
287
+
288
+ const createAstroComponentEntries = ({ entries, manifest, root }) => {
289
+ const componentEntry = createAstroComponentEntry({ entries, manifest, root })
290
+
291
+ return componentEntry ? [componentEntry] : []
292
+ }
293
+
125
294
  const scanAstroSourceDomMarkers = (root, manifest, options = {}) => {
126
295
  const markerAttribute = getMarkerAttribute(manifest, options)
127
296
  const entries = []
@@ -132,6 +301,7 @@ const scanAstroSourceDomMarkers = (root, manifest, options = {}) => {
132
301
  status: 'unavailable',
133
302
  markerAttribute,
134
303
  entries,
304
+ componentEntries: [],
135
305
  missing,
136
306
  reason: manifest?.reason || 'Astro source manifest is unavailable.',
137
307
  }
@@ -142,6 +312,7 @@ const scanAstroSourceDomMarkers = (root, manifest, options = {}) => {
142
312
  status: 'unavailable',
143
313
  markerAttribute,
144
314
  entries,
315
+ componentEntries: [],
145
316
  missing,
146
317
  reason: 'A DOM root with querySelectorAll() is required.',
147
318
  }
@@ -165,6 +336,7 @@ const scanAstroSourceDomMarkers = (root, manifest, options = {}) => {
165
336
  status: 'ready',
166
337
  markerAttribute,
167
338
  entries,
339
+ componentEntries: createAstroComponentEntries({ entries, manifest, root }),
168
340
  missing,
169
341
  }
170
342
  }
@@ -194,17 +366,16 @@ const ensurePinegrowAstroBridge = (win = getDefaultWindow()) => {
194
366
  win.pinegrow.watchFromContext = createFallbackWatch
195
367
  }
196
368
 
197
- if (!isMapLike(win.pinegrow.elCache)) {
198
- win.pinegrow.elCache = new Map()
199
- }
369
+ win.pinegrow.elCache = createReactiveMap(win.pinegrow, win.pinegrow.elCache)
200
370
 
201
371
  if (!win.pinegrow.astro) {
202
372
  win.pinegrow.astro = {}
203
373
  }
204
374
 
205
- if (!isMapLike(win.pinegrow.astro.sourceManifests)) {
206
- win.pinegrow.astro.sourceManifests = new Map()
207
- }
375
+ win.pinegrow.astro.sourceManifests = createReactiveMap(
376
+ win.pinegrow,
377
+ win.pinegrow.astro.sourceManifests
378
+ )
208
379
 
209
380
  return win.pinegrow
210
381
  }
@@ -283,7 +454,9 @@ const refreshAstroElCache = (manifest, options = {}) => {
283
454
  : removeAstroEntriesForManifest(pinegrow.elCache, manifest)
284
455
  const updatedElements = new Set(removal.elements)
285
456
 
286
- scan.entries.forEach(entry => {
457
+ const cacheEntries = [...scan.entries, ...(scan.componentEntries || [])]
458
+
459
+ cacheEntries.forEach(entry => {
287
460
  upsertAstroEntry(pinegrow.elCache, entry)
288
461
  updatedElements.add(entry.el)
289
462
  })
@@ -302,7 +475,7 @@ const refreshAstroElCache = (manifest, options = {}) => {
302
475
 
303
476
  return {
304
477
  ...scan,
305
- cached: scan.entries.length,
478
+ cached: cacheEntries.length,
306
479
  removed: removal.removed,
307
480
  }
308
481
  }
@@ -318,6 +491,7 @@ const createAstroRuntimeBridge = (manifest, options = {}) => ({
318
491
  })
319
492
 
320
493
  export {
494
+ createAstroComponentEntries,
321
495
  createAstroElCacheEntry,
322
496
  createAstroRuntimeBridge,
323
497
  ensurePinegrowAstroBridge,
@@ -1 +1 @@
1
- (()=>{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},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},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,u,i,l=[],a=!0,s=!1;try{if(u=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=u.call(r)).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{if(!a&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return l}},e.exports.__esModule=!0,e.exports.default=e.exports},147: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},681:(e,t,r)=>{var n=r(314),o=r(193),u=r(121),i=r(147);e.exports=function(e,t){return n(e)||o(e,t)||u(e,t)||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}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var u=t[n]={exports:{}};return e[n](u,u.exports,r),u.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,{createAstroElCacheEntry:()=>v,createAstroRuntimeBridge:()=>x,ensurePinegrowAstroBridge:()=>g,refreshAstroElCache:()=>b,scanAstroSourceDomMarkers:()=>y});var e=r(290),t=r(681);function o(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 u(t){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?o(Object(n),!0).forEach((function(r){e(t,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var i="astro",l=function(e){return{get value(){return e()}}},a=function(e){return{value:e}},s=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(){}},c=function(e,t){return{uid:"astro:".concat(t.id),isMounted:!0,isUnmounted:!1,type:{__name:t.name||"AstroElement",__file:e.sourceFile||null},appContext:null}},f=function(){return"undefined"!=typeof window?window:null},p=function(e){return e&&"function"==typeof e.get&&"function"==typeof e.set&&"function"==typeof e.delete&&"function"==typeof e.entries},d=function(e){return(null==e?void 0:e.sourceFile)||(null==e?void 0:e.id)||null},m=function(e){return Array.isArray(e)?e:[]},v=function(e){var t,r,n=e.element,o=e.manifest,u=e.node,l={start:null!==(t=u.sourceStart)&&void 0!==t?t:null,end:null!==(r=u.sourceEnd)&&void 0!==r?r:null,status:u.sourceRangeStatus||"unknown"};return{el:n,framework:i,isAstro:!0,sourceId:u.id,pgId:u.id,key:u.id,localFile:o.sourceFile||null,sourceFile:o.sourceFile||null,nodeType:u.type||null,name:u.name||"",sourceRange:l,sourceStart:l.start,sourceEnd:l.end,sourceRangeStatus:l.status,marker:u.marker||null,editability:u.editability||null,attributes:u.attributes||[],isFragment:!1,isRootFragment:!1,isIsland:!1,rootEl:null,firstEl:n,lastEl:n,instance:c(o,u),vnode:null}},y=function(e,t){var r=function(e){var t;return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).markerAttribute||(null==e||null===(t=e.marker)||void 0===t?void 0:t.attribute)||"data-pg-source-id"}(t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}),n=[],o=[];if("ready"!==(null==t?void 0:t.status))return{status:"unavailable",markerAttribute:r,entries:n,missing:o,reason:(null==t?void 0:t.reason)||"Astro source manifest is unavailable."};if(!e||"function"!=typeof e.querySelectorAll)return{status:"unavailable",markerAttribute:r,entries:n,missing:o,reason:"A DOM root with querySelectorAll() is required."};var u=function(e){var t=new Map;return((null==e?void 0:e.nodes)||[]).forEach((function(e){null!=e&&e.id&&t.set(e.id,e)})),t}(t);return function(e,t){return e&&"function"==typeof e.querySelectorAll?Array.from(e.querySelectorAll("[".concat(t,"]"))):[]}(e,r).forEach((function(e){var i=function(e,t){return e&&"function"==typeof e.getAttribute?e.getAttribute(t):null}(e,r),l=u.get(i);l?n.push(v({element:e,manifest:t,node:l})):o.push({element:e,sourceId:i})})),{status:"ready",markerAttribute:r,entries:n,missing:o}},g=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:f();return e?(e.pinegrow||(e.pinegrow={}),"function"!=typeof e.pinegrow.reactiveFromContext&&(e.pinegrow.reactiveFromContext=function(e){return e}),"function"!=typeof e.pinegrow.refFromContext&&(e.pinegrow.refFromContext=a),"function"!=typeof e.pinegrow.computedFromContext&&(e.pinegrow.computedFromContext=l),"function"!=typeof e.pinegrow.watchFromContext&&(e.pinegrow.watchFromContext=s),p(e.pinegrow.elCache)||(e.pinegrow.elCache=new Map),e.pinegrow.astro||(e.pinegrow.astro={}),p(e.pinegrow.astro.sourceManifests)||(e.pinegrow.astro.sourceManifests=new Map),e.pinegrow):null},b=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.win||f(),o=r.root||(null==n?void 0:n.document)||null,l=g(n),a=y(o,e,r);if(!l)return u(u({},a),{},{cached:0,removed:0,reason:a.reason||"A browser window is required."});if("ready"!==a.status)return u(u({},a),{},{cached:0,removed:0});var s=!1===r.clearPrevious?{elements:[],removed:0}:function(e,r){var n=d(r),o=0,u=[];return n?(Array.from(e.entries()).forEach((function(r){var l=t(r,2),a=l[0],s=l[1],c=m(s),f=c.filter((function(e){return!function(e,t){return(null==e?void 0:e.framework)===i&&(e.localFile===t||e.sourceFile===t)}(e,n)})),p=c.length-f.length;o+=p,p&&u.push(a),f.length?e.set(a,f):e.delete(a)})),{elements:u,removed:o}):{elements:u,removed:o}}(l.elCache,e),c=new Set(s.elements);a.entries.forEach((function(e){!function(e,t){var r=m(e.get(t.el)).filter((function(e){return e.framework!==i||e.sourceId!==t.sourceId||e.localFile!==t.localFile}));r.push(t),e.set(t.el,r)}(l.elCache,e),c.add(e.el)})),c.forEach((function(e){l.elUpdateHanderFn&&l.elUpdateHanderFn(e)}));var p=d(e);return p&&l.astro.sourceManifests.set(p,e),u(u({},a),{},{cached:a.entries.length,removed:s.removed})},x=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{manifest:e,scan:function(r){var n,o;return y(r||t.root||(null===(n=t.win)||void 0===n?void 0:n.document)||(null===(o=f())||void 0===o?void 0:o.document),e,t)},refresh:function(r){return b(e,u(u({},t),r))}}}})(),module.exports=n})();
1
+ (()=>{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},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,u,i,l=[],s=!0,a=!1;try{if(u=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=u.call(r)).done)&&(l.push(n.value),l.length!==t);s=!0);}catch(e){a=!0,o=e}finally{try{if(!s&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(a)throw o}}return l}},e.exports.__esModule=!0,e.exports.default=e.exports},147: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},681:(e,t,r)=>{var n=r(314),o=r(193),u=r(121),i=r(147);e.exports=function(e,t){return n(e)||o(e,t)||u(e,t)||i()},e.exports.__esModule=!0,e.exports.default=e.exports},408:(e,t,r)=>{var n=r(850),o=r(912),u=r(121),i=r(96);e.exports=function(e){return n(e)||o(e)||u(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}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var u=t[n]={exports:{}};return e[n](u,u.exports,r),u.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,{createAstroComponentEntries:()=>w,createAstroElCacheEntry:()=>x,createAstroRuntimeBridge:()=>S,ensurePinegrowAstroBridge:()=>A,refreshAstroElCache:()=>_,scanAstroSourceDomMarkers:()=>h});var e=r(408),t=r(290),o=r(681);function u(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 i(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?u(Object(n),!0).forEach((function(r){t(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var l="astro",s=function(e){return{get value(){return e()}}},a=function(e){return{value:e}},c=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(){}},p=function(e,t){return{uid:"astro:".concat(e.id),isMounted:!0,isUnmounted:!1,parent:null,type:{__name:e.name||"AstroElement",__file:null},props:{},attrs:{},slots:{},subTree:{el:t},appContext:null}},f=function(){return"undefined"!=typeof window?window:null},d=function(e,t){var r=function(e){return e&&"function"==typeof e.get&&"function"==typeof e.set&&"function"==typeof e.delete&&"function"==typeof e.entries}(t)?t:new Map,n=null==e?void 0:e.reactiveFromContext;return"function"==typeof n?n(r):r},m=function(e){return(null==e?void 0:e.sourceFile)||(null==e?void 0:e.id)||null},y=function(e){return Array.isArray(e)?e:[]},v=function(e){return"".concat(e||"").replace(/\\/g,"/")},g=function(e){return e&&v(e).split("/").pop()||""},b=function(e,t,r){return{uid:t,isMounted:!0,isUnmounted:!1,parent:null,type:{__name:g(null==e?void 0:e.sourceFile)||"AstroComponent",__file:(null==e?void 0:e.sourceFile)||null},props:{},attrs:{},slots:{},subTree:{el:r},appContext:null}},x=function(e){var t,r,n=e.element,o=e.manifest,u=e.node,i={start:null!==(t=u.sourceStart)&&void 0!==t?t:null,end:null!==(r=u.sourceEnd)&&void 0!==r?r:null,status:u.sourceRangeStatus||"unknown"};return{el:n,framework:l,entryKind:"source-node",treeScopes:{pageTree:!0,appTree:!1},isAstro:!0,isAstroSourceDomEntry:!0,isAstroComponent:!1,isAppTreeComponent:!1,sourceId:u.id,pgId:u.id,key:u.id,localFile:null,sourceFile:o.sourceFile||null,nodeType:u.type||null,name:u.name||"",source:{id:u.id,file:o.sourceFile||null,range:i,nodeType:u.type||null,name:u.name||""},component:null,owners:[],sourceRange:i,sourceStart:i.start,sourceEnd:i.end,sourceRangeStatus:i.status,marker:u.marker||null,editability:u.editability||null,attributes:u.attributes||[],isFragment:!1,isRootFragment:!1,isIsland:!1,rootEl:null,firstEl:n,lastEl:n,instance:p(u,n),vnode:null}},w=function(e){var t=function(e){var t=e.entries,r=e.manifest,n=e.root,o=null==r?void 0:r.sourceFile,u=function(e){return e?e.documentElement?e.documentElement:e.body?e.body:e.firstElementChild?e.firstElementChild:1===e.nodeType?e:null:null}(n),i=function(e){return/(^|\/)src\/pages\/.+\.astro$/i.test(v(e))}(o),s=i&&u;if(!o||!t.length&&!s)return null;var a=t[0],c=t[t.length-1],p="astro-component:".concat(o),f=s?u:a.firstEl||a.el,d=s?null:c.lastEl||c.el,m=g(o);return{el:f,framework:l,entryKind:s?"page-root":"component-boundary",treeScopes:{pageTree:!1,appTree:!0},isAstro:!0,isAstroSourceDomEntry:!1,isAstroComponent:!0,isAppTreeComponent:!0,isAstroPageRoot:Boolean(s),sourceId:p,pgId:null,key:null,localFile:o,sourceFile:o,nodeType:"component-file",name:m,source:{id:p,file:o,range:{start:null,end:null,status:"component-file"},nodeType:"component-file",name:m},component:{file:o,name:m,kind:i?"page":"component"},owners:[],sourceRange:{start:null,end:null,status:"component-file"},sourceStart:null,sourceEnd:null,sourceRangeStatus:"component-file",marker:null,editability:{mode:"inspect",operations:["select","open-source-file"],reasons:["astro-component-file"]},attributes:[],isFragment:!1,isRootFragment:!1,isIsland:!1,rootEl:null,firstEl:f,lastEl:d,instance:b(r,p,f),vnode:null}}({entries:e.entries,manifest:e.manifest,root:e.root});return t?[t]:[]},h=function(e,t){var r=function(e){var t;return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).markerAttribute||(null==e||null===(t=e.marker)||void 0===t?void 0:t.attribute)||"data-pg-source-id"}(t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}),n=[],o=[];if("ready"!==(null==t?void 0:t.status))return{status:"unavailable",markerAttribute:r,entries:n,componentEntries:[],missing:o,reason:(null==t?void 0:t.reason)||"Astro source manifest is unavailable."};if(!e||"function"!=typeof e.querySelectorAll)return{status:"unavailable",markerAttribute:r,entries:n,componentEntries:[],missing:o,reason:"A DOM root with querySelectorAll() is required."};var u=function(e){var t=new Map;return((null==e?void 0:e.nodes)||[]).forEach((function(e){null!=e&&e.id&&t.set(e.id,e)})),t}(t);return function(e,t){return e&&"function"==typeof e.querySelectorAll?Array.from(e.querySelectorAll("[".concat(t,"]"))):[]}(e,r).forEach((function(e){var i=function(e,t){return e&&"function"==typeof e.getAttribute?e.getAttribute(t):null}(e,r),l=u.get(i);l?n.push(x({element:e,manifest:t,node:l})):o.push({element:e,sourceId:i})})),{status:"ready",markerAttribute:r,entries:n,componentEntries:w({entries:n,manifest:t,root:e}),missing:o}},A=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:f();return e?(e.pinegrow||(e.pinegrow={}),"function"!=typeof e.pinegrow.reactiveFromContext&&(e.pinegrow.reactiveFromContext=function(e){return e}),"function"!=typeof e.pinegrow.refFromContext&&(e.pinegrow.refFromContext=a),"function"!=typeof e.pinegrow.computedFromContext&&(e.pinegrow.computedFromContext=s),"function"!=typeof e.pinegrow.watchFromContext&&(e.pinegrow.watchFromContext=c),e.pinegrow.elCache=d(e.pinegrow,e.pinegrow.elCache),e.pinegrow.astro||(e.pinegrow.astro={}),e.pinegrow.astro.sourceManifests=d(e.pinegrow,e.pinegrow.astro.sourceManifests),e.pinegrow):null},_=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.win||f(),u=r.root||(null==n?void 0:n.document)||null,s=A(n),a=h(u,t,r);if(!s)return i(i({},a),{},{cached:0,removed:0,reason:a.reason||"A browser window is required."});if("ready"!==a.status)return i(i({},a),{},{cached:0,removed:0});var c=!1===r.clearPrevious?{elements:[],removed:0}:function(e,t){var r=m(t),n=0,u=[];return r?(Array.from(e.entries()).forEach((function(t){var i=o(t,2),s=i[0],a=i[1],c=y(a),p=c.filter((function(e){return!function(e,t){return(null==e?void 0:e.framework)===l&&(e.localFile===t||e.sourceFile===t)}(e,r)})),f=c.length-p.length;n+=f,f&&u.push(s),p.length?e.set(s,p):e.delete(s)})),{elements:u,removed:n}):{elements:u,removed:n}}(s.elCache,t),p=new Set(c.elements),d=[].concat(e(a.entries),e(a.componentEntries||[]));d.forEach((function(e){!function(e,t){var r=y(e.get(t.el)).filter((function(e){return e.framework!==l||e.sourceId!==t.sourceId||e.localFile!==t.localFile}));r.push(t),e.set(t.el,r)}(s.elCache,e),p.add(e.el)})),p.forEach((function(e){s.elUpdateHanderFn&&s.elUpdateHanderFn(e)}));var v=m(t);return v&&s.astro.sourceManifests.set(v,t),i(i({},a),{},{cached:d.length,removed:c.removed})},S=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{manifest:e,scan:function(r){var n,o;return h(r||t.root||(null===(n=t.win)||void 0===n?void 0:n.document)||(null===(o=f())||void 0===o?void 0:o.document),e,t)},refresh:function(r){return _(e,i(i({},t),r))}}}})(),module.exports=n})();
@@ -1,4 +1,5 @@
1
1
  export {
2
+ createAstroComponentEntries,
2
3
  createAstroElCacheEntry,
3
4
  createAstroRuntimeBridge,
4
5
  ensurePinegrowAstroBridge,
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@pinegrow/vite-plugin",
3
- "version": "3.0.73-alpha.1",
3
+ "version": "3.0.73-alpha.5",
4
4
  "description": "Pinegrow Vite Plugin",
5
5
  "type": "module",
6
- "files": [
7
- "dist",
8
- "./types.d.ts",
9
- "./astro.d.ts",
10
- "./astro-runtime.d.ts"
11
- ],
6
+ "files": [
7
+ "dist",
8
+ "./types.d.ts",
9
+ "./astro.d.ts",
10
+ "./astro-runtime.d.ts"
11
+ ],
12
12
  "main": "./dist/index.cjs",
13
13
  "module": "./dist/index.mjs",
14
14
  "types": "./types.d.ts",
@@ -17,25 +17,25 @@
17
17
  "types": "./types.d.ts",
18
18
  "import": "./dist/index.mjs",
19
19
  "require": "./dist/index.cjs"
20
- },
21
- "./dev": {
22
- "import": "./src/index.dev.js",
23
- "require": "./src/index.dev.js"
24
- },
25
- "./vue": {
26
- "import": "./dist/vue/index.js"
27
- },
28
- "./astro": {
29
- "types": "./astro.d.ts",
30
- "import": "./dist/astro/index.mjs",
31
- "require": "./dist/astro/index.cjs"
32
- },
33
- "./astro/runtime": {
34
- "types": "./astro-runtime.d.ts",
35
- "import": "./dist/astro/runtime.mjs",
36
- "require": "./dist/astro/runtime.cjs"
37
- }
38
- },
20
+ },
21
+ "./dev": {
22
+ "import": "./src/index.dev.js",
23
+ "require": "./src/index.dev.js"
24
+ },
25
+ "./vue": {
26
+ "import": "./dist/vue/index.js"
27
+ },
28
+ "./astro": {
29
+ "types": "./astro.d.ts",
30
+ "import": "./dist/astro/index.mjs",
31
+ "require": "./dist/astro/index.cjs"
32
+ },
33
+ "./astro/runtime": {
34
+ "types": "./astro-runtime.d.ts",
35
+ "import": "./dist/astro/runtime.mjs",
36
+ "require": "./dist/astro/runtime.cjs"
37
+ }
38
+ },
39
39
  "keywords": [
40
40
  "pinegrow",
41
41
  "vue designer",
@@ -46,23 +46,23 @@
46
46
  ],
47
47
  "author": "Pinegrow (http://pinegrow.com/)",
48
48
  "license": "MIT",
49
- "scripts": {
50
- "build": "webpack -- --env mode=production vite",
51
- "build:vite-plugin": "webpack -- --env mode=production vite",
52
- "build:vite-plugin:dev": "webpack -- --env mode=development vite",
53
- "test": "node --test test/*.test.mjs",
54
- "publish-alpha": "npm run increment-alpha-version && npm publish --tag alpha",
55
- "increment-alpha-version": "npm version prerelease --preid=alpha",
56
- "publish-beta": "npm run increment-beta-version && npm publish --tag beta",
49
+ "scripts": {
50
+ "build": "webpack -- --env mode=production vite",
51
+ "build:vite-plugin": "webpack -- --env mode=production vite",
52
+ "build:vite-plugin:dev": "webpack -- --env mode=development vite",
53
+ "test": "node --test test/*.test.mjs",
54
+ "publish-alpha": "npm run increment-alpha-version && npm publish --tag alpha",
55
+ "increment-alpha-version": "npm version prerelease --preid=alpha",
56
+ "publish-beta": "npm run increment-beta-version && npm publish --tag beta",
57
57
  "increment-beta-version": "npm version prerelease --preid=beta",
58
58
  "publish-patch": "npm run increment-version && npm publish",
59
59
  "increment-version": "npm version patch"
60
60
  },
61
- "dependencies": {
62
- "@vue/compiler-sfc": "^3.2.45",
63
- "magic-string": "^0.27.0"
64
- },
65
- "devDependencies": {
66
- "@astrojs/compiler": "^2.2.1"
67
- }
68
- }
61
+ "dependencies": {
62
+ "@vue/compiler-sfc": "^3.2.45",
63
+ "magic-string": "^0.27.0"
64
+ },
65
+ "devDependencies": {
66
+ "@astrojs/compiler": "^2.2.1"
67
+ }
68
+ }