@pinegrow/nuxt-module 3.0.0-beta.134 → 3.0.0-beta.135

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2021
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2021
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,67 +1,67 @@
1
- <!-- [![@pinegrow/nuxt-module](https://tailwindcss.nuxtjs.org/social-card.png)](https://tailwindcss.nuxtjs.org) -->
2
-
3
- # Pinegrow Nuxt Module
4
-
5
- [![npm version][npm-version-src]][npm-version-href]
6
- [![npm downloads][npm-downloads-src]][npm-downloads-href]
7
- [![License][license-src]][license-href]
8
-
9
- [Nuxt](https://nuxt.com/) module for [Pinegrow](https://pinegrow.com) ⚡️
10
-
11
- Pinegrow Nuxt Module enables connection and interaction between your Vite Dev-Server and Pinegrow apps (currently only Vue Designer).
12
-
13
- - [📖 &nbsp;Documentation](https://pinegrow.com/vue-designer)
14
-
15
- ## Features
16
-
17
- - 🎨&nbsp; Visually live-design your Vite-powered Nuxt apps
18
- - ⚙️&nbsp; Smartly integrates into your Nuxt workflow in dev-mode only
19
- - ✨&nbsp; No lock-in, Pinegrow is an open-tool ❤️
20
-
21
- ## Quick Setup
22
-
23
- 1. Install: Add `@pinegrow/nuxt-module` to your project
24
-
25
- ```bash
26
- # Using npm
27
- npm install --save-dev @pinegrow/nuxt-module
28
-
29
- # Using pnpm
30
- pnpm add --save-dev @pinegrow/nuxt-module
31
- ```
32
-
33
- 2. Configure: Add `@pinegrow/nuxt-module` to your Nuxt Integrations array `nuxt.config.{js,ts}`
34
-
35
- ```js
36
- //nuxt.config.js (or) nuxt.config.ts
37
-
38
- export default defineNuxtConfig({
39
- modules: [
40
- '@pinegrow/nuxt-module',
41
- //...
42
- ],
43
- pinegrow: {
44
- liveDesigner: {
45
- //...
46
- },
47
- },
48
- //...
49
- })
50
- ```
51
-
52
- Now, open your project in your Pinegrow app (currently only Vue Designer). ✨
53
-
54
- ## License
55
-
56
- [MIT License](./LICENSE)
57
-
58
- Copyright (c) Pinegrow
59
-
60
- <!-- Badges -->
61
-
62
- [npm-version-src]: https://img.shields.io/npm/v/@pinegrow/nuxt-module/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
63
- [npm-version-href]: https://npmjs.com/package/@pinegrow/nuxt-module
64
- [npm-downloads-src]: https://img.shields.io/npm/dm/@pinegrow/nuxt-module.svg?style=flat&colorA=18181B&colorB=28CF8D
65
- [npm-downloads-href]: https://npmjs.com/package/@pinegrow/nuxt-module
66
- [license-src]: https://img.shields.io/npm/l/@pinegrow/nuxt-module.svg?style=flat&colorA=18181B&colorB=28CF8D
67
- [license-href]: https://npmjs.com/package/@pinegrow/nuxt-module
1
+ <!-- [![@pinegrow/nuxt-module](https://tailwindcss.nuxtjs.org/social-card.png)](https://tailwindcss.nuxtjs.org) -->
2
+
3
+ # Pinegrow Nuxt Module
4
+
5
+ [![npm version][npm-version-src]][npm-version-href]
6
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
7
+ [![License][license-src]][license-href]
8
+
9
+ [Nuxt](https://nuxt.com/) module for [Pinegrow](https://pinegrow.com) ⚡️
10
+
11
+ Pinegrow Nuxt Module enables connection and interaction between your Vite Dev-Server and Pinegrow apps (currently only Vue Designer).
12
+
13
+ - [📖 &nbsp;Documentation](https://pinegrow.com/vue-designer)
14
+
15
+ ## Features
16
+
17
+ - 🎨&nbsp; Visually live-design your Vite-powered Nuxt apps
18
+ - ⚙️&nbsp; Smartly integrates into your Nuxt workflow in dev-mode only
19
+ - ✨&nbsp; No lock-in, Pinegrow is an open-tool ❤️
20
+
21
+ ## Quick Setup
22
+
23
+ 1. Install: Add `@pinegrow/nuxt-module` to your project
24
+
25
+ ```bash
26
+ # Using npm
27
+ npm install --save-dev @pinegrow/nuxt-module
28
+
29
+ # Using pnpm
30
+ pnpm add --save-dev @pinegrow/nuxt-module
31
+ ```
32
+
33
+ 2. Configure: Add `@pinegrow/nuxt-module` to your Nuxt Integrations array `nuxt.config.{js,ts}`
34
+
35
+ ```js
36
+ //nuxt.config.js (or) nuxt.config.ts
37
+
38
+ export default defineNuxtConfig({
39
+ modules: [
40
+ '@pinegrow/nuxt-module',
41
+ //...
42
+ ],
43
+ pinegrow: {
44
+ liveDesigner: {
45
+ //...
46
+ },
47
+ },
48
+ //...
49
+ })
50
+ ```
51
+
52
+ Now, open your project in your Pinegrow app (currently only Vue Designer). ✨
53
+
54
+ ## License
55
+
56
+ [MIT License](./LICENSE)
57
+
58
+ Copyright (c) Pinegrow
59
+
60
+ <!-- Badges -->
61
+
62
+ [npm-version-src]: https://img.shields.io/npm/v/@pinegrow/nuxt-module/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
63
+ [npm-version-href]: https://npmjs.com/package/@pinegrow/nuxt-module
64
+ [npm-downloads-src]: https://img.shields.io/npm/dm/@pinegrow/nuxt-module.svg?style=flat&colorA=18181B&colorB=28CF8D
65
+ [npm-downloads-href]: https://npmjs.com/package/@pinegrow/nuxt-module
66
+ [license-src]: https://img.shields.io/npm/l/@pinegrow/nuxt-module.svg?style=flat&colorA=18181B&colorB=28CF8D
67
+ [license-href]: https://npmjs.com/package/@pinegrow/nuxt-module
@@ -1,7 +1,7 @@
1
1
  import pkg from '@pinegrow/vite-plugin';
2
2
 
3
- // import { liveDesigner } from '@pinegrow/vite-plugin/dev'
4
-
3
+ // import { liveDesigner } from '@pinegrow/vite-plugin/dev'
4
+
5
5
  const liveDesigner = pkg.liveDesigner;
6
6
 
7
7
  export { liveDesigner };
package/dist/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.1.0"
6
6
  },
7
- "version": "3.0.0-beta.133"
7
+ "version": "3.0.0-beta.134"
8
8
  }
@@ -1,5 +1,5 @@
1
- // import { liveDesigner } from '@pinegrow/vite-plugin/dev'
2
-
3
- import pkg from '@pinegrow/vite-plugin'
4
- const liveDesigner = pkg.liveDesigner
5
- export { liveDesigner }
1
+ // import { liveDesigner } from '@pinegrow/vite-plugin/dev'
2
+
3
+ import pkg from '@pinegrow/vite-plugin'
4
+ const liveDesigner = pkg.liveDesigner
5
+ export { liveDesigner }
@@ -1,223 +1,223 @@
1
- import { defineNitroPlugin } from 'nitropack/runtime/plugin'
2
- // import { fileURLToPath, URL } from 'node:url'
3
- // import htmlParser from 'node-html-parser'
4
- import path from 'path'
5
- import fs from 'fs'
6
-
7
- export default defineNitroPlugin(async nitroApp => {
8
- // const nitroInstance = nitroApp
9
- // const runtimeConfig = await nitroInstance.hooks.callHook(
10
- // 'nitro-runtime'
11
- // )
12
-
13
- nitroApp.hooks.hook('render:html', async (htmlContext, { event }) => {
14
- // console.log('render:html', htmlContext)
15
- // htmlContext.bodyAppend.push('<hr>Appended by custom plugin')
16
-
17
- // const runtimeConfig = await nitroInstance.hooks.callHook(
18
- // 'transform-index-html',
19
- // htmlContext
20
- // )
21
- const projectRoot = process.cwd()
22
-
23
- // https://github.com/unjs/nitro/discussions/1080
24
-
25
- const addons = [
26
- {
27
- name: 'pgia',
28
- resources: [
29
- {
30
- // condition: 'interactions',
31
- parentResource: `public/pgia`, // relative to project root, must exists
32
- // source: `<script src="pgia/index.js"></script>`,
33
- injectTo: 'head-append',
34
- tag: 'script',
35
- children: `
36
- /* Pinegrow Interactions, do not remove */ (function(){try{if(!document.documentElement.hasAttribute('data-pg-ia-disabled')) { window.pgia_small_mq=typeof pgia_small_mq=='string'?pgia_small_mq:'(max-width:767px)';window.pgia_large_mq=typeof pgia_large_mq=='string'?pgia_large_mq:'(min-width:768px)';var style = document.createElement('style');var pgcss='html:not(.pg-ia-no-preview) [data-pg-ia-hide=""] {opacity:0;visibility:hidden;}html:not(.pg-ia-no-preview) [data-pg-ia-show=""] {opacity:1;visibility:visible;display:block;}';if(document.documentElement.hasAttribute('data-pg-id') && document.documentElement.hasAttribute('data-pg-mobile')) {pgia_small_mq='(min-width:0)';pgia_large_mq='(min-width:99999px)'} pgcss+='@media ' + pgia_small_mq + '{ html:not(.pg-ia-no-preview) [data-pg-ia-hide="mobile"] {opacity:0;visibility:hidden;}html:not(.pg-ia-no-preview) [data-pg-ia-show="mobile"] {opacity:1;visibility:visible;display:block;}}';pgcss+='@media ' + pgia_large_mq + '{html:not(.pg-ia-no-preview) [data-pg-ia-hide="desktop"] {opacity:0;visibility:hidden;}html:not(.pg-ia-no-preview) [data-pg-ia-show="desktop"] {opacity:1;visibility:visible;display:block;}}';style.innerHTML=pgcss;document.querySelector('head').appendChild(style);}}catch(e){console&&console.log(e);}})()`,
37
- },
38
- {
39
- // condition: 'interactions',
40
- parentResource: `public/pgia`, // relative to project root, must exists
41
- injectTo: 'body-append',
42
- tag: 'script',
43
- attrs: { src: '/pgia/lib/index.js' },
44
- },
45
- ],
46
- },
47
- ]
48
-
49
- addons.forEach(addon => {
50
- addon.resources.forEach(resource => {
51
- if (
52
- !resource.condition /*|| this.customOptions[resource.condition] */
53
- ) {
54
- try {
55
- let parentResourceExists = true
56
-
57
- if (resource.parentResource) {
58
- const resourcePath = path.resolve(
59
- projectRoot,
60
- resource.parentResource
61
- )
62
- parentResourceExists =
63
- parentResourceExists &&
64
- fs.existsSync(resourcePath)
65
- }
66
-
67
- if (parentResourceExists) {
68
- const attrContent = Object.entries(
69
- resource.attrs || {}
70
- ).reduce((acc, [key, value]) => {
71
- return `${acc}${key}${
72
- value && value !== true ? `="${value}"` : ''
73
- }`
74
- }, '')
75
-
76
- switch (resource.injectTo) {
77
- case 'head-prepend':
78
- case 'head-append':
79
- htmlContext.head.push(`<${
80
- resource.tag
81
- } ${attrContent}>
82
- ${resource.children || ''}
83
- </${resource.tag}>`)
84
- break
85
-
86
- case 'body-prepend':
87
- htmlContext.bodyPrepend.push(`<${
88
- resource.tag
89
- } ${attrContent}>
90
- ${resource.children || ''}
91
- </${resource.tag}>`)
92
- break
93
-
94
- case 'body-append':
95
- htmlContext.bodyAppend.push(`<${
96
- resource.tag
97
- } ${attrContent}>
98
- ${resource.children || ''}
99
- </${resource.tag}>`)
100
- break
101
- }
102
- }
103
- } catch (err) {
104
- console.log(err)
105
- }
106
- }
107
- })
108
- })
109
-
110
- // const dev_server_url = event.req.headers.referer // event.req.headers.host
111
- // const pinegrow_url = process.env.pinegrow_url
112
-
113
- // if (pinegrow_url) {
114
- // const pinegrow_base_url = new URL(pinegrow_url)
115
- // pinegrow_base_url.port = pinegrow_base_url.port - 1
116
-
117
- // htmlContext.head = htmlContext.head.reduce((acc, headItem) => {
118
- // if (headItem.startsWith('<link')) {
119
- // try {
120
- // const linkNode = htmlParser.parse(headItem, 'text/html')
121
- // // .childNodes[0]
122
- // const linkHref = linkNode.getAttribute('href')
123
- // const linkPath = path.resolve(
124
- // projectRoot,
125
- // `${linkHref}` // `.${linkHref}`
126
- // )
127
- // if (fs.existsSync(linkPath)) {
128
- // linkNode.setAttribute(
129
- // 'href',
130
- // new URL(
131
- // path.relative(projectRoot, linkHref),
132
- // pinegrow_base_url
133
- // ).href
134
- // )
135
- // }
136
- // return [...acc, linkNode.outerHTML]
137
- // } catch (err) {
138
- // // console.log(err)
139
- // }
140
- // }
141
- // return [...acc, headItem]
142
- // }, [])
143
-
144
- // // Auto add css file from public folder, so that pinegrow thinks it is loaded from internal server
145
- // const publicFolder = path.resolve(projectRoot, 'public')
146
- // if (isExistsAndDirectory(publicFolder)) {
147
- // fs.readdirSync(publicFolder).forEach(fileName => {
148
- // const folderPath = publicFolder
149
- // const filePath = path.resolve(folderPath, fileName)
150
- // const fileExtn = path.extname(fileName)
151
-
152
- // if (isFile(filePath) && fileExtn === '.css') {
153
- // const linkHref = new URL(
154
- // path.relative(projectRoot, filePath),
155
- // dev_server_url //pinegrow_base_url
156
- // ).href
157
- // htmlContext.head.push(
158
- // `<link ref="stylesheet" href="${linkHref}">`
159
- // // `<link ref="stylesheet" href="./${linkHref}">`
160
- // )
161
- // // const linkHref = new URL(
162
- // // path.relative(projectRoot, filePath),
163
- // // pinegrow_base_url
164
- // // ).href
165
- // // // const linkHref = path.relative(projectRoot, filePath)
166
- // // htmlContext.head.push(
167
- // // // `<link ref="stylesheet" href="${linkHref}">`
168
- // // `<link ref="stylesheet" href="${linkHref}">`
169
- // // )
170
- // // htmlContext.head.push(
171
- // // // `<link ref="stylesheet" href="${linkHref}">`
172
- // // `<link ref="stylesheet" href="file://${filePath}">`
173
- // // )
174
- // }
175
- // })
176
- // }
177
- // }
178
- })
179
- // nitroApp.hooks.hook('render:response', (response, { event }) => {
180
- // console.log('render:response', response)
181
- // })
182
- })
183
-
184
- // var isExistsAndFile = filePath => isExistsPath(filePath) && isFile(filePath)
185
-
186
- // var isExistsAndDirectory = filePath =>
187
- // isExistsPath(filePath) && isDirectory(filePath)
188
-
189
- // var isExistsPath = (filePath, root) => {
190
- // const fullPath = toAbsolutePath(filePath, root)
191
- // return !!(fullPath && fs.existsSync(fullPath))
192
- // }
193
-
194
- // var isFile = (filePath, root) => {
195
- // const fullPath = toAbsolutePath(filePath, root)
196
- // return !!(fullPath && fs.statSync(fullPath).isFile())
197
- // }
198
-
199
- // var isDirectory = (filePath, root) => {
200
- // const fullPath = toAbsolutePath(filePath, root)
201
- // return !!(fullPath && fs.statSync(fullPath).isDirectory())
202
- // }
203
-
204
- // var toAbsolutePath = (filePath, root, searchDir) => {
205
- // try {
206
- // if (path.isAbsolute(filePath)) {
207
- // return filePath
208
- // } else {
209
- // if (root) {
210
- // if (searchDir) {
211
- // return path.resolve(root, searchDir, filePath)
212
- // } else {
213
- // return path.resolve(root, filePath)
214
- // }
215
- // } else {
216
- // // No root, no project
217
- // return false
218
- // }
219
- // }
220
- // } catch (err) {
221
- // console.log(err)
222
- // }
223
- // }
1
+ import { defineNitroPlugin } from 'nitropack/runtime/plugin'
2
+ // import { fileURLToPath, URL } from 'node:url'
3
+ // import htmlParser from 'node-html-parser'
4
+ import path from 'path'
5
+ import fs from 'fs'
6
+
7
+ export default defineNitroPlugin(async nitroApp => {
8
+ // const nitroInstance = nitroApp
9
+ // const runtimeConfig = await nitroInstance.hooks.callHook(
10
+ // 'nitro-runtime'
11
+ // )
12
+
13
+ nitroApp.hooks.hook('render:html', async (htmlContext, { event }) => {
14
+ // console.log('render:html', htmlContext)
15
+ // htmlContext.bodyAppend.push('<hr>Appended by custom plugin')
16
+
17
+ // const runtimeConfig = await nitroInstance.hooks.callHook(
18
+ // 'transform-index-html',
19
+ // htmlContext
20
+ // )
21
+ const projectRoot = process.cwd()
22
+
23
+ // https://github.com/unjs/nitro/discussions/1080
24
+
25
+ const addons = [
26
+ {
27
+ name: 'pgia',
28
+ resources: [
29
+ {
30
+ // condition: 'interactions',
31
+ parentResource: `public/pgia`, // relative to project root, must exists
32
+ // source: `<script src="pgia/index.js"></script>`,
33
+ injectTo: 'head-append',
34
+ tag: 'script',
35
+ children: `
36
+ /* Pinegrow Interactions, do not remove */ (function(){try{if(!document.documentElement.hasAttribute('data-pg-ia-disabled')) { window.pgia_small_mq=typeof pgia_small_mq=='string'?pgia_small_mq:'(max-width:767px)';window.pgia_large_mq=typeof pgia_large_mq=='string'?pgia_large_mq:'(min-width:768px)';var style = document.createElement('style');var pgcss='html:not(.pg-ia-no-preview) [data-pg-ia-hide=""] {opacity:0;visibility:hidden;}html:not(.pg-ia-no-preview) [data-pg-ia-show=""] {opacity:1;visibility:visible;display:block;}';if(document.documentElement.hasAttribute('data-pg-id') && document.documentElement.hasAttribute('data-pg-mobile')) {pgia_small_mq='(min-width:0)';pgia_large_mq='(min-width:99999px)'} pgcss+='@media ' + pgia_small_mq + '{ html:not(.pg-ia-no-preview) [data-pg-ia-hide="mobile"] {opacity:0;visibility:hidden;}html:not(.pg-ia-no-preview) [data-pg-ia-show="mobile"] {opacity:1;visibility:visible;display:block;}}';pgcss+='@media ' + pgia_large_mq + '{html:not(.pg-ia-no-preview) [data-pg-ia-hide="desktop"] {opacity:0;visibility:hidden;}html:not(.pg-ia-no-preview) [data-pg-ia-show="desktop"] {opacity:1;visibility:visible;display:block;}}';style.innerHTML=pgcss;document.querySelector('head').appendChild(style);}}catch(e){console&&console.log(e);}})()`,
37
+ },
38
+ {
39
+ // condition: 'interactions',
40
+ parentResource: `public/pgia`, // relative to project root, must exists
41
+ injectTo: 'body-append',
42
+ tag: 'script',
43
+ attrs: { src: '/pgia/lib/index.js' },
44
+ },
45
+ ],
46
+ },
47
+ ]
48
+
49
+ addons.forEach(addon => {
50
+ addon.resources.forEach(resource => {
51
+ if (
52
+ !resource.condition /*|| this.customOptions[resource.condition] */
53
+ ) {
54
+ try {
55
+ let parentResourceExists = true
56
+
57
+ if (resource.parentResource) {
58
+ const resourcePath = path.resolve(
59
+ projectRoot,
60
+ resource.parentResource
61
+ )
62
+ parentResourceExists =
63
+ parentResourceExists &&
64
+ fs.existsSync(resourcePath)
65
+ }
66
+
67
+ if (parentResourceExists) {
68
+ const attrContent = Object.entries(
69
+ resource.attrs || {}
70
+ ).reduce((acc, [key, value]) => {
71
+ return `${acc}${key}${
72
+ value && value !== true ? `="${value}"` : ''
73
+ }`
74
+ }, '')
75
+
76
+ switch (resource.injectTo) {
77
+ case 'head-prepend':
78
+ case 'head-append':
79
+ htmlContext.head.push(`<${
80
+ resource.tag
81
+ } ${attrContent}>
82
+ ${resource.children || ''}
83
+ </${resource.tag}>`)
84
+ break
85
+
86
+ case 'body-prepend':
87
+ htmlContext.bodyPrepend.push(`<${
88
+ resource.tag
89
+ } ${attrContent}>
90
+ ${resource.children || ''}
91
+ </${resource.tag}>`)
92
+ break
93
+
94
+ case 'body-append':
95
+ htmlContext.bodyAppend.push(`<${
96
+ resource.tag
97
+ } ${attrContent}>
98
+ ${resource.children || ''}
99
+ </${resource.tag}>`)
100
+ break
101
+ }
102
+ }
103
+ } catch (err) {
104
+ console.log(err)
105
+ }
106
+ }
107
+ })
108
+ })
109
+
110
+ // const dev_server_url = event.req.headers.referer // event.req.headers.host
111
+ // const pinegrow_url = process.env.pinegrow_url
112
+
113
+ // if (pinegrow_url) {
114
+ // const pinegrow_base_url = new URL(pinegrow_url)
115
+ // pinegrow_base_url.port = pinegrow_base_url.port - 1
116
+
117
+ // htmlContext.head = htmlContext.head.reduce((acc, headItem) => {
118
+ // if (headItem.startsWith('<link')) {
119
+ // try {
120
+ // const linkNode = htmlParser.parse(headItem, 'text/html')
121
+ // // .childNodes[0]
122
+ // const linkHref = linkNode.getAttribute('href')
123
+ // const linkPath = path.resolve(
124
+ // projectRoot,
125
+ // `${linkHref}` // `.${linkHref}`
126
+ // )
127
+ // if (fs.existsSync(linkPath)) {
128
+ // linkNode.setAttribute(
129
+ // 'href',
130
+ // new URL(
131
+ // path.relative(projectRoot, linkHref),
132
+ // pinegrow_base_url
133
+ // ).href
134
+ // )
135
+ // }
136
+ // return [...acc, linkNode.outerHTML]
137
+ // } catch (err) {
138
+ // // console.log(err)
139
+ // }
140
+ // }
141
+ // return [...acc, headItem]
142
+ // }, [])
143
+
144
+ // // Auto add css file from public folder, so that pinegrow thinks it is loaded from internal server
145
+ // const publicFolder = path.resolve(projectRoot, 'public')
146
+ // if (isExistsAndDirectory(publicFolder)) {
147
+ // fs.readdirSync(publicFolder).forEach(fileName => {
148
+ // const folderPath = publicFolder
149
+ // const filePath = path.resolve(folderPath, fileName)
150
+ // const fileExtn = path.extname(fileName)
151
+
152
+ // if (isFile(filePath) && fileExtn === '.css') {
153
+ // const linkHref = new URL(
154
+ // path.relative(projectRoot, filePath),
155
+ // dev_server_url //pinegrow_base_url
156
+ // ).href
157
+ // htmlContext.head.push(
158
+ // `<link ref="stylesheet" href="${linkHref}">`
159
+ // // `<link ref="stylesheet" href="./${linkHref}">`
160
+ // )
161
+ // // const linkHref = new URL(
162
+ // // path.relative(projectRoot, filePath),
163
+ // // pinegrow_base_url
164
+ // // ).href
165
+ // // // const linkHref = path.relative(projectRoot, filePath)
166
+ // // htmlContext.head.push(
167
+ // // // `<link ref="stylesheet" href="${linkHref}">`
168
+ // // `<link ref="stylesheet" href="${linkHref}">`
169
+ // // )
170
+ // // htmlContext.head.push(
171
+ // // // `<link ref="stylesheet" href="${linkHref}">`
172
+ // // `<link ref="stylesheet" href="file://${filePath}">`
173
+ // // )
174
+ // }
175
+ // })
176
+ // }
177
+ // }
178
+ })
179
+ // nitroApp.hooks.hook('render:response', (response, { event }) => {
180
+ // console.log('render:response', response)
181
+ // })
182
+ })
183
+
184
+ // var isExistsAndFile = filePath => isExistsPath(filePath) && isFile(filePath)
185
+
186
+ // var isExistsAndDirectory = filePath =>
187
+ // isExistsPath(filePath) && isDirectory(filePath)
188
+
189
+ // var isExistsPath = (filePath, root) => {
190
+ // const fullPath = toAbsolutePath(filePath, root)
191
+ // return !!(fullPath && fs.existsSync(fullPath))
192
+ // }
193
+
194
+ // var isFile = (filePath, root) => {
195
+ // const fullPath = toAbsolutePath(filePath, root)
196
+ // return !!(fullPath && fs.statSync(fullPath).isFile())
197
+ // }
198
+
199
+ // var isDirectory = (filePath, root) => {
200
+ // const fullPath = toAbsolutePath(filePath, root)
201
+ // return !!(fullPath && fs.statSync(fullPath).isDirectory())
202
+ // }
203
+
204
+ // var toAbsolutePath = (filePath, root, searchDir) => {
205
+ // try {
206
+ // if (path.isAbsolute(filePath)) {
207
+ // return filePath
208
+ // } else {
209
+ // if (root) {
210
+ // if (searchDir) {
211
+ // return path.resolve(root, searchDir, filePath)
212
+ // } else {
213
+ // return path.resolve(root, filePath)
214
+ // }
215
+ // } else {
216
+ // // No root, no project
217
+ // return false
218
+ // }
219
+ // }
220
+ // } catch (err) {
221
+ // console.log(err)
222
+ // }
223
+ // }
package/package.json CHANGED
@@ -1,53 +1,53 @@
1
- {
2
- "name": "@pinegrow/nuxt-module",
3
- "version": "3.0.0-beta.134",
4
- "description": "Pinegrow Nuxt Module",
5
- "author": "Pinegrow (http://pinegrow.com/)",
6
- "license": "MIT",
7
- "type": "module",
8
- "files": [
9
- "dist"
10
- ],
11
- "main": "./dist/module.cjs",
12
- "module": "./dist/module.cjs",
13
- "exports": {
14
- ".": {
15
- "import": "./dist/module.mjs",
16
- "require": "./dist/module.cjs"
17
- }
18
- },
19
- "types": "./dist/types.d.ts",
20
- "keywords": [
21
- "pinegrow",
22
- "vue-designer",
23
- "nuxt-module",
24
- "@pinegrow/nuxt-module"
25
- ],
26
- "scripts": {
27
- "build": "npm run dev:prepare && npm run build:module",
28
- "build:module": "nuxt-module-build",
29
- "dev": "nuxi dev playground",
30
- "dev:build": "nuxi build playground",
31
- "dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
32
- "publish-beta": "npm run increment-beta-version && npm publish",
33
- "increment-beta-version": "npm version prerelease --preid=beta",
34
- "lint": "npm run lint:fix && npm run format",
35
- "lint:fix": "eslint --ext .js,.cjs,.ts,.vue --ignore-path .gitignore --fix ./src",
36
- "format": "prettier --write ."
37
- },
38
- "dependencies": {
39
- "@nuxt/kit": "latest",
40
- "@pinegrow/vite-plugin": "3.0.0-beta.134"
41
- },
42
- "devDependencies": {
43
- "@nuxt/module-builder": "latest",
44
- "@nuxt/eslint-config": "^0.1.1",
45
- "nuxt": "^3.1.0",
46
- "eslint": "^8.35.0",
47
- "eslint-config-prettier": "^8.7.0",
48
- "prettier": "^2.8.4"
49
- },
50
- "peerDependencies": {
51
- "nuxt": "^3.1.0"
52
- }
53
- }
1
+ {
2
+ "name": "@pinegrow/nuxt-module",
3
+ "version": "3.0.0-beta.135",
4
+ "description": "Pinegrow Nuxt Module",
5
+ "author": "Pinegrow (http://pinegrow.com/)",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "main": "./dist/module.cjs",
12
+ "module": "./dist/module.cjs",
13
+ "exports": {
14
+ ".": {
15
+ "import": "./dist/module.mjs",
16
+ "require": "./dist/module.cjs"
17
+ }
18
+ },
19
+ "types": "./dist/types.d.ts",
20
+ "keywords": [
21
+ "pinegrow",
22
+ "vue-designer",
23
+ "nuxt-module",
24
+ "@pinegrow/nuxt-module"
25
+ ],
26
+ "scripts": {
27
+ "build": "npm run dev:prepare && npm run build:module",
28
+ "build:module": "nuxt-module-build",
29
+ "dev": "nuxi dev playground",
30
+ "dev:build": "nuxi build playground",
31
+ "dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
32
+ "publish-beta": "npm run increment-beta-version && npm publish",
33
+ "increment-beta-version": "npm version prerelease --preid=beta",
34
+ "lint": "npm run lint:fix && npm run format",
35
+ "lint:fix": "eslint --ext .js,.cjs,.ts,.vue --ignore-path .gitignore --fix ./src",
36
+ "format": "prettier --write ."
37
+ },
38
+ "dependencies": {
39
+ "@nuxt/kit": "latest",
40
+ "@pinegrow/vite-plugin": "3.0.0-beta.135"
41
+ },
42
+ "devDependencies": {
43
+ "@nuxt/module-builder": "latest",
44
+ "@nuxt/eslint-config": "^0.1.1",
45
+ "nuxt": "^3.1.0",
46
+ "eslint": "^8.35.0",
47
+ "eslint-config-prettier": "^8.7.0",
48
+ "prettier": "^2.8.4"
49
+ },
50
+ "peerDependencies": {
51
+ "nuxt": "^3.1.0"
52
+ }
53
+ }