@pinegrow/nuxt-module 3.0.0-beta.8 → 3.0.0-beta.80

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  # @pinegrow/nuxt-module
2
2
 
3
- ## Nuxt module for Pinegrow
3
+ ## Pinegrow Nuxt module
4
4
 
5
5
  http://www.pinegrow.com
package/dist/module.d.ts CHANGED
@@ -2,10 +2,13 @@ import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
3
  interface ModuleOptions {
4
4
  liveDesigner?: {
5
+ [key in string]?: any;
6
+ } & {
5
7
  repoRoot?: string;
6
8
  configPath?: string;
7
9
  plugins?: string[];
8
- usingStandaloneVueDevtools?: boolean;
10
+ devtoolsKey?: string;
11
+ vscodeTunnelUrl?: string;
9
12
  customTypes?: {
10
13
  default?: {};
11
14
  };
package/dist/module.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "pinegrow",
3
3
  "configKey": "pinegrow",
4
4
  "compatibility": {
5
- "nuxt": "^3.0.0 || ~3.0.0-rc"
5
+ "nuxt": "^3.1.0"
6
6
  },
7
- "version": "3.0.0-beta.7"
7
+ "version": "3.0.0-beta.79"
8
8
  }
package/dist/module.mjs CHANGED
@@ -1,34 +1,89 @@
1
- import { defineNuxtModule, addVitePlugin } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addServerPlugin, useNitro, addVitePlugin } from '@nuxt/kit';
2
2
 
3
3
  const module = defineNuxtModule({
4
4
  meta: {
5
+ // Usually npm package name of your module
5
6
  name: "pinegrow",
7
+ // The key in `nuxt.config` that holds your module options
6
8
  configKey: "pinegrow",
9
+ // Compatibility constraints
7
10
  compatibility: {
8
- nuxt: "^3.0.0 || ~3.0.0-rc"
11
+ // Semver version of supported nuxt versions
12
+ nuxt: "^3.1.0"
9
13
  }
10
14
  },
15
+ // Default configuration options for your module
11
16
  defaults: {
12
17
  liveDesigner: {
18
+ // repoRoot: './',
19
+ // configPath: './',
13
20
  plugins: [],
14
- usingStandaloneVueDevtools: false,
21
+ // devtoolsKey: 'devtools',
22
+ // vscodeTunnelUrl: 'https://vscode.dev/tunnel/hostname',
23
+ // iconsets: [],
24
+ // routerHistoryMode: 'html5',
25
+ // mergeWithPackageJson: {
26
+ // dependencies: {},
27
+ // devDependencies: {},
28
+ // },
15
29
  customTypes: {
16
- default: {}
30
+ // To apply type overrides to a specific component (overrides above default fn),
31
+ // ComponentName: { prop: { customType: 'icon' } },
32
+ // VRating: {
33
+ // ripple: {
34
+ // customType: "boolean",
35
+ // },
36
+ // },
37
+ // VSelect: {
38
+ // variant: {
39
+ // customType: 'select',
40
+ // options: ['plain', 'outlined', 'underlined', 'solo'],
41
+ // default: ''
42
+ // },
43
+ // density: {
44
+ // customType: 'select',
45
+ // options: ['default', 'compact', 'comfortable']
46
+ // },
47
+ // disabled: {
48
+ // customType: 'boolean'
49
+ // },
50
+ // appendIcon: {
51
+ // customType: 'icon'
52
+ // },
53
+ // }
54
+ // To apply type overrides to all components,
55
+ // all: { prop: { customType: 'icon' } },
56
+ default: {
57
+ // density: {
58
+ // customType: "select",
59
+ // // add options when customType is 'select'
60
+ // options: ["default", "compact", "comfortable"],
61
+ // },
62
+ }
63
+ },
64
+ tailwindcss: {
65
+ cssPath: "./assets/css/tailwind.css"
17
66
  }
18
67
  }
19
68
  },
20
69
  hooks: {},
21
70
  async setup(moduleOptions, nuxt) {
22
71
  if (moduleOptions.liveDesigner) {
72
+ const { resolve } = createResolver(import.meta.url);
73
+ addServerPlugin(resolve("./runtime/nitro-plugin.mjs"));
74
+ const nuxtInstance = nuxt;
75
+ let pluginInstance;
23
76
  nuxt.hook("listen", async (listenerServer) => {
24
77
  try {
25
78
  const { liveDesigner } = await import('./chunks/live-designer.mjs');
26
- addVitePlugin(
27
- liveDesigner({
28
- ...moduleOptions.liveDesigner,
29
- listenerServer
30
- })
31
- );
79
+ const nitroApp = useNitro();
80
+ pluginInstance = liveDesigner({
81
+ ...moduleOptions.liveDesigner,
82
+ listenerServer,
83
+ nuxtInstance,
84
+ nitroApp
85
+ });
86
+ addVitePlugin(pluginInstance);
32
87
  } catch (err) {
33
88
  console.log(err);
34
89
  console.log(
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,81 @@
1
+ import { defineNitroPlugin } from 'nitropack/runtime/plugin'
2
+ import path from 'path'
3
+ import fs from 'fs'
4
+
5
+ export default defineNitroPlugin(nitroApp => {
6
+ // const nitroInstance = nitroApp
7
+
8
+ nitroApp.hooks.hook('render:html', (html /*, { event }*/) => {
9
+ // console.log('render:html', html)
10
+ // html.bodyAppend.push('<hr>Appended by custom plugin')
11
+
12
+ const addons = [
13
+ {
14
+ name: 'pgia',
15
+ resources: [
16
+ {
17
+ parent: 'head',
18
+ parentResource: `public/pgia`, // relative to project root, must exists
19
+ // source: `<script src="pgia/index.js"></script>`,
20
+ source: `<script>/* 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);}})()</script>`,
21
+ operation: 'append',
22
+ },
23
+ {
24
+ parent: 'body',
25
+ parentResource: `public/pgia`, // relative to project root, must exists
26
+ source: `<script src="/pgia/lib/index.js"></script>`,
27
+ operation: 'append',
28
+ },
29
+ ],
30
+ },
31
+ ]
32
+
33
+ addons.forEach(addon => {
34
+ addon.resources.forEach(resource => {
35
+ try {
36
+ let parentResourceExists = true
37
+
38
+ if (resource.parentResource) {
39
+ const projectRoot = process.cwd()
40
+ const resourcePath = path.resolve(
41
+ projectRoot,
42
+ resource.parentResource
43
+ )
44
+ parentResourceExists =
45
+ parentResourceExists && fs.existsSync(resourcePath)
46
+ }
47
+
48
+ if (parentResourceExists) {
49
+ switch (resource.operation) {
50
+ case 'prepend':
51
+ switch (resource.parent) {
52
+ case 'head':
53
+ html.head.push(resource.source)
54
+ break
55
+ case 'body':
56
+ html.bodyPrepend.push(resource.source)
57
+ break
58
+ }
59
+ break
60
+ case 'append':
61
+ switch (resource.parent) {
62
+ case 'head':
63
+ html.head.push(resource.source)
64
+ break
65
+ case 'body':
66
+ html.bodyAppend.push(resource.source)
67
+ break
68
+ }
69
+ break
70
+ }
71
+ }
72
+ } catch (err) {
73
+ // console.log(err)
74
+ }
75
+ })
76
+ })
77
+ })
78
+ // nitroApp.hooks.hook('render:response', (response, { event }) => {
79
+ // console.log('render:response', response)
80
+ // })
81
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinegrow/nuxt-module",
3
- "version": "3.0.0-beta.8",
3
+ "version": "3.0.0-beta.80",
4
4
  "description": "Pinegrow Nuxt Module",
5
5
  "author": "Pinegrow (http://pinegrow.com/)",
6
6
  "license": "MIT",
@@ -28,16 +28,21 @@
28
28
  "dev:build": "nuxi build playground",
29
29
  "dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
30
30
  "publish-beta": "npm run increment-beta-version && npm publish",
31
- "increment-beta-version": "npm version prerelease --preid=beta"
31
+ "increment-beta-version": "npm version prerelease --preid=beta",
32
+ "lint": "npm run lint:fix && npm run format",
33
+ "lint:fix": "eslint --ext .js,.cjs,.ts,.vue --ignore-path .gitignore --fix ./src",
34
+ "format": "prettier --write ."
32
35
  },
33
36
  "dependencies": {
34
37
  "@nuxt/kit": "latest",
35
- "@pinegrow/vite-plugin": "latest"
38
+ "@pinegrow/vite-plugin": "3.0.0-beta.80"
36
39
  },
37
40
  "devDependencies": {
38
41
  "@nuxt/module-builder": "latest",
39
- "@nuxtjs/eslint-config-typescript": "latest",
40
- "eslint": "latest",
41
- "nuxt": "rc"
42
+ "@nuxt/eslint-config": "^0.1.1",
43
+ "nuxt": "^3.1.0",
44
+ "eslint": "^8.35.0",
45
+ "eslint-config-prettier": "^8.7.0",
46
+ "prettier": "^2.8.4"
42
47
  }
43
48
  }