@pinegrow/vite-plugin 3.0.0-beta.99 → 3.0.1
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.
- package/README.md +167 -3
- package/dist/index.cjs +73502 -2
- package/dist/index.cjs.map +1 -0
- package/dist/vue/index.js +27 -83
- package/package.json +7 -6
- package/types.d.ts +105 -12
- package/dist/index.cjs.LICENSE.txt +0 -794
package/dist/vue/index.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
onBeforeMount,
|
|
3
|
+
onMounted,
|
|
4
|
+
onBeforeUnmount,
|
|
5
|
+
getCurrentInstance,
|
|
6
|
+
ref,
|
|
7
|
+
reactive,
|
|
8
|
+
onUpdated,
|
|
9
|
+
computed,
|
|
10
|
+
watch,
|
|
11
|
+
} from 'vue'
|
|
2
12
|
|
|
3
13
|
export function usePinegrow() {
|
|
4
14
|
const initCache = () => {
|
|
@@ -7,8 +17,7 @@ export function usePinegrow() {
|
|
|
7
17
|
|
|
8
18
|
if (!(winObj?.process?.client && winObj.process.client !== true)) {
|
|
9
19
|
if (!winObj.pinegrow) {
|
|
10
|
-
//
|
|
11
|
-
// console.log('Cache initialized by Pinegrow Vue Plugin!')
|
|
20
|
+
// console.log('Cache initialized by Vue Plugin!')
|
|
12
21
|
const elCache = reactive(new Map())
|
|
13
22
|
|
|
14
23
|
const enrichWithComponentName = (elCacheObj, localFile) => {
|
|
@@ -19,90 +28,18 @@ export function usePinegrow() {
|
|
|
19
28
|
}
|
|
20
29
|
}
|
|
21
30
|
|
|
22
|
-
const pgIdToElComputed = computed(() => {
|
|
23
|
-
const pgIds = {}
|
|
24
|
-
for (let [el, elCacheNodes] of elCache.entries()) {
|
|
25
|
-
if (el.isConnected) {
|
|
26
|
-
elCacheNodes.forEach(elCacheObj => {
|
|
27
|
-
if (
|
|
28
|
-
elCacheObj.instance.isMounted &&
|
|
29
|
-
!elCacheObj.instance.isUnmounted &&
|
|
30
|
-
elCacheObj.pgId &&
|
|
31
|
-
(!elCacheObj.rootEl || elCacheObj.isRootFragment)
|
|
32
|
-
) {
|
|
33
|
-
if (!pgIds[elCacheObj.pgId]) {
|
|
34
|
-
pgIds[elCacheObj.pgId] = []
|
|
35
|
-
}
|
|
36
|
-
if (elCacheObj.key === undefined || elCacheObj.key === null) {
|
|
37
|
-
pgIds[elCacheObj.pgId].push(elCacheObj)
|
|
38
|
-
} else {
|
|
39
|
-
pgIds[elCacheObj.pgId].push([elCacheObj.key, elCacheObj])
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return pgIds
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
const localComponentToElComputed = computed(() => {
|
|
49
|
-
const localComponents = {}
|
|
50
|
-
for (let [el, elCacheNodes] of elCache.entries()) {
|
|
51
|
-
if (el.isConnected) {
|
|
52
|
-
elCacheNodes.forEach(elCacheObj => {
|
|
53
|
-
if (
|
|
54
|
-
elCacheObj.instance.isMounted &&
|
|
55
|
-
!elCacheObj.instance.isUnmounted &&
|
|
56
|
-
elCacheObj.localFile
|
|
57
|
-
// && !elCacheObj.isIsland
|
|
58
|
-
// && (!elCacheObj.rootEl || elCacheObj.isRootFragment)
|
|
59
|
-
) {
|
|
60
|
-
if (!localComponents[elCacheObj.localFile]) {
|
|
61
|
-
localComponents[elCacheObj.localFile] = []
|
|
62
|
-
}
|
|
63
|
-
// There might be a elCache that was hydrated, and has the ile-root as a parent. If it was already there, then update the iles-root instead of adding a new node
|
|
64
|
-
const possibleIslandRootIndex = localComponents[elCacheObj.localFile].findIndex(
|
|
65
|
-
prevElCacheObj =>
|
|
66
|
-
prevElCacheObj.isIsland &&
|
|
67
|
-
prevElCacheObj.firstEl?.firstElementChild === elCacheObj.el
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
if (possibleIslandRootIndex > -1) {
|
|
71
|
-
const pgId = localComponents[elCacheObj.localFile][possibleIslandRootIndex].pgId
|
|
72
|
-
localComponents[elCacheObj.localFile][possibleIslandRootIndex] =
|
|
73
|
-
enrichWithComponentName({ ...elCacheObj, pgId }, elCacheObj.localFile)
|
|
74
|
-
} else {
|
|
75
|
-
localComponents[elCacheObj.localFile].push(
|
|
76
|
-
enrichWithComponentName(elCacheObj, elCacheObj.localFile)
|
|
77
|
-
)
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return localComponents
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
const appTree = computed(() => {
|
|
87
|
-
const appTreeNodes = Object.values(localComponentToElComputed.value).reduce(
|
|
88
|
-
(acc, localComponent) => [...acc, ...localComponent],
|
|
89
|
-
[]
|
|
90
|
-
)
|
|
91
|
-
const appTreeNodesSorted = appTreeNodes.sort((a, b) =>
|
|
92
|
-
a.el.compareDocumentPosition(b.el) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1
|
|
93
|
-
)
|
|
94
|
-
return appTreeNodesSorted
|
|
95
|
-
})
|
|
96
|
-
|
|
97
31
|
winObj.pinegrow = {
|
|
98
32
|
elCache,
|
|
33
|
+
// pgIdToElComputed,
|
|
34
|
+
// localComponentToElComputed,
|
|
35
|
+
// appTree,
|
|
36
|
+
reactiveFromContext: reactive,
|
|
37
|
+
refFromContext: ref,
|
|
38
|
+
computedFromContext: computed,
|
|
39
|
+
watchFromContext: watch,
|
|
99
40
|
// // Uncomment these two to test locally
|
|
100
41
|
// elCacheErrHandlerFn,
|
|
101
42
|
// elUpdateHanderFn,
|
|
102
|
-
// rootFragmentToPgIdComputed,
|
|
103
|
-
pgIdToElComputed,
|
|
104
|
-
localComponentToElComputed,
|
|
105
|
-
appTree,
|
|
106
43
|
}
|
|
107
44
|
}
|
|
108
45
|
}
|
|
@@ -115,10 +52,11 @@ export function usePinegrow() {
|
|
|
115
52
|
if (!window.pinegrow) initCache()
|
|
116
53
|
|
|
117
54
|
let el = vnode.el
|
|
118
|
-
if (!el) return
|
|
119
55
|
|
|
120
56
|
const instance = vnode.component || vnode.ctx || el.__vueParentComponent
|
|
121
57
|
|
|
58
|
+
if (!el || !instance) return
|
|
59
|
+
|
|
122
60
|
try {
|
|
123
61
|
if ((key !== null && key !== undefined) || (vnode.key !== null && vnode.key !== undefined)) {
|
|
124
62
|
key = vnode.key || key
|
|
@@ -334,6 +272,9 @@ export function usePinegrow() {
|
|
|
334
272
|
} else {
|
|
335
273
|
pinegrow.elCache.delete(el)
|
|
336
274
|
}
|
|
275
|
+
if (pinegrow.elUpdateHanderFn) {
|
|
276
|
+
pinegrow.elUpdateHanderFn(el)
|
|
277
|
+
}
|
|
337
278
|
}
|
|
338
279
|
}
|
|
339
280
|
|
|
@@ -363,6 +304,9 @@ export function usePinegrow() {
|
|
|
363
304
|
mountLocalComponent()
|
|
364
305
|
})
|
|
365
306
|
onBeforeUnmount(() => unmountLocalComponent())
|
|
307
|
+
onUpdated(() => {
|
|
308
|
+
mountLocalComponent()
|
|
309
|
+
})
|
|
366
310
|
|
|
367
311
|
return { pgUpdateElCache }
|
|
368
312
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pinegrow/vite-plugin",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Pinegrow Vite Plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"types": "./types.d.ts",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
+
"types": "./types.d.ts",
|
|
15
16
|
"import": "./dist/index.cjs",
|
|
16
17
|
"require": "./dist/index.cjs"
|
|
17
18
|
},
|
|
@@ -21,15 +22,14 @@
|
|
|
21
22
|
},
|
|
22
23
|
"./vue": {
|
|
23
24
|
"import": "./dist/vue/index.js"
|
|
24
|
-
},
|
|
25
|
-
"./pgia": {
|
|
26
|
-
"import": "./dist/pgia/index.js"
|
|
27
25
|
}
|
|
28
26
|
},
|
|
29
27
|
"keywords": [
|
|
30
28
|
"pinegrow",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
29
|
+
"vue designer",
|
|
30
|
+
"vuedesigner",
|
|
31
|
+
"vue-designer",
|
|
32
|
+
"vite-plugin",
|
|
33
33
|
"@pinegrow/vite-plugin"
|
|
34
34
|
],
|
|
35
35
|
"author": "Pinegrow (http://pinegrow.com/)",
|
|
@@ -46,3 +46,4 @@
|
|
|
46
46
|
"node-html-parser": "^5.2.0"
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
+
|
package/types.d.ts
CHANGED
|
@@ -1,13 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
// https://vuedesigner.com
|
|
2
|
+
|
|
3
|
+
import type { PinegrowTailwindCSSModuleOptions } from '@pinegrow/tailwindcss-plugin'
|
|
4
|
+
import type { PluginOption as VitePluginOption } from 'vite'
|
|
5
|
+
|
|
6
|
+
interface PinegrowExternalPlugin {
|
|
7
|
+
/**
|
|
8
|
+
* Display name in Props Panel and Library Panels
|
|
9
|
+
* Eg, "My Awesome Lib 3.3.1", defaults to key if not provided
|
|
10
|
+
*/
|
|
11
|
+
name?: string
|
|
12
|
+
/**
|
|
13
|
+
* Unique key that doesn't conflict with other pinegrow frameworks
|
|
14
|
+
* Run `Object.values(pinegrow.getFrameworks()).map(fx => fx.key)` in Vue Designer's devtools console for existing keys
|
|
15
|
+
*
|
|
16
|
+
* Allowed characters - alphanumeric with hyphens or period, no spaces
|
|
17
|
+
* Eg, 'my-awesome-lib'
|
|
18
|
+
*/
|
|
19
|
+
key: string
|
|
20
|
+
/**
|
|
21
|
+
* Web-types of component library (or) pinegrow commonjs plugin
|
|
22
|
+
* Must return an absolute path
|
|
23
|
+
*
|
|
24
|
+
* Use path functions according to the project module type (commonjs/module)
|
|
25
|
+
* For eg, path.resolve(__dirname, '../my-awesome-lib/web-types.json')
|
|
26
|
+
* (or)
|
|
27
|
+
* import { fileURLToPath, URL } from 'node:url'
|
|
28
|
+
* fileURLToPath(new URL('./relative-path/web-types.json', import.meta.url)) // web-types of component library
|
|
29
|
+
* fileURLToPath(new URL('./my-awesome-lib/web-types.json', import.meta.url)) // pinegrow commonjs plugin
|
|
30
|
+
*/
|
|
31
|
+
pluginPath: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface LiveDesignerOptions {
|
|
35
|
+
/**
|
|
36
|
+
* When your project is part of a mono-repo
|
|
37
|
+
* Absolute path to the root of a monorepo (or)
|
|
38
|
+
* Relative path from the project root to the root of a monorepo.
|
|
39
|
+
*/
|
|
40
|
+
repoRoot?: string
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* When using a custom config file (for eg, vite-dev.config.js)
|
|
44
|
+
* Absolute path to a custom config file (for eg, vite-dev.config.js) (or)
|
|
45
|
+
* Relative path from the project root to a custom config file (for eg, vite-dev.config.js).
|
|
46
|
+
*/
|
|
47
|
+
configPath?: string
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Key of the devtools exposed on the window object.
|
|
51
|
+
* For instructions, check Config Panel > Devtools tab in Vue Designer
|
|
52
|
+
*/
|
|
53
|
+
devtoolsKey?: string
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Preferred format for icons in icon-picker - https://github.com/antfu/icones/blob/main/src/utils/case.ts
|
|
57
|
+
* * @default 'unocss' // For eg, i-material-symbols-home
|
|
58
|
+
* * When using Nuxt-Icon, you need to change this to 'iconify'
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
iconPreferredCase?:
|
|
62
|
+
| 'unocss'
|
|
63
|
+
| 'iconify'
|
|
64
|
+
| 'bare'
|
|
65
|
+
| 'barePascal'
|
|
66
|
+
| 'dash'
|
|
67
|
+
| 'slash'
|
|
68
|
+
| 'doubleHyphen'
|
|
69
|
+
| 'camel'
|
|
70
|
+
| 'pascal'
|
|
71
|
+
| 'component'
|
|
72
|
+
| 'componentKebab'
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Router history modes - 'html5', 'hash'
|
|
76
|
+
* @default 'html5'
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
routerHistoryMode?: string
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Array of Pinegrow plugins (npm package names)
|
|
83
|
+
* To use file-based Pinegrow Plugins, provide the absolute path of the plugin file, for eg, [path.resolve(__dirname, './pg-plugin/index.js')] as pluginPath, along with a unique key
|
|
84
|
+
*/
|
|
85
|
+
plugins?: PinegrowExternalPlugin[] | string | string[]
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Pinegrow TailwindCSS plugin options
|
|
89
|
+
* For options, refer to https://www.npmjs.com/package/@pinegrow/tailwindcss-plugin
|
|
90
|
+
*/
|
|
91
|
+
tailwindcss?: PinegrowTailwindCSSModuleOptions
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface PinegrowVitePlugin<VitePluginOption> {
|
|
95
|
+
/**
|
|
96
|
+
* Pinegrow Live Designer options
|
|
97
|
+
*/
|
|
98
|
+
liveDesigner?: {
|
|
99
|
+
[key in string]?: any
|
|
100
|
+
} & LiveDesignerOptions
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
declare function export_default(liveDesigner: LiveDesignerOptions): PinegrowVitePlugin
|
|
104
|
+
|
|
105
|
+
export { PinegrowVitePlugin, LiveDesignerOptions, export_default as default, export_default as liveDesigner }
|
|
13
106
|
|