@pinegrow/iles-module 0.0.1-beta.3 → 3.0.0-beta.101

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,38 +1,6 @@
1
- <p align="center">
2
- <a href="https://iles-docs.netlify.app">
3
- <img src="https://github.com/ElMassimo/iles/blob/main/docs/images/banner.png"/>
4
- </a>
5
- </p>
1
+ # @pinegrow/iles-module
6
2
 
7
- <p align="center">
8
- <table>
9
- <tbody>
10
- <td align="center">
11
- <br/>
12
- <p align="center">
13
- <h3><samp>iles-module</samp></h3>
14
- <img width="2000" height="0">
15
- </p>
16
- </td>
17
- </tbody>
18
- </table>
19
- </p>
3
+ ## Pinegrow Iles module
20
4
 
21
- [îles]: https://github.com/ElMassimo/iles
5
+ http://www.pinegrow.com
22
6
 
23
- An [îles] module that...
24
-
25
- - ⚡️ helps you with...
26
-
27
- ### Usage 🚀
28
-
29
- ```ts
30
- // iles.config.ts
31
- import { defineConfig } from 'iles'
32
-
33
- export default defineConfig({
34
- modules: [
35
- 'iles-module',
36
- ],
37
- })
38
- ```
package/dist/index.cjs CHANGED
@@ -1,30 +1,168 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/index.ts
2
- async function src_default(moduleOptions) {
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/index.ts
2
+ var _nodehtmlparser = require('node-html-parser'); var _nodehtmlparser2 = _interopRequireDefault(_nodehtmlparser);
3
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
4
+ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
5
+ var _vite = require('unplugin-auto-import/vite'); var _vite2 = _interopRequireDefault(_vite);
6
+ async function getViteConfiguration(moduleOptions) {
7
+ var _a;
3
8
  let vitePlugin;
4
9
  try {
5
- const { liveDesigner } = await Promise.resolve().then(() => require("./live-designer-ZFVVYPVH.cjs"));
6
- vitePlugin = liveDesigner({
7
- ...moduleOptions.liveDesigner
8
- });
10
+ const { liveDesigner } = await Promise.resolve().then(() => require("./live-designer-PEHWBCFL.cjs"));
11
+ vitePlugin = liveDesigner(moduleOptions == null ? void 0 : moduleOptions.liveDesigner);
9
12
  } catch (err) {
10
13
  console.log(err);
11
14
  console.log("Pinegrow: @pinegrow/iles-module was unable to load @pinegrow/vite-plugin live-designer!");
12
15
  }
16
+ const config = {
17
+ plugins: vitePlugin ? [vitePlugin] : []
18
+ };
19
+ const isObject$1 = (value) => {
20
+ return Object.prototype.toString.call(value) === "[object Object]";
21
+ };
22
+ const arraify = (target) => {
23
+ return Array.isArray(target) ? target : [target];
24
+ };
25
+ const mergeConfigRecursively = (defaults, overrides) => {
26
+ const merged = { ...defaults };
27
+ for (const key in overrides) {
28
+ const value = overrides[key];
29
+ if (value == null) {
30
+ continue;
31
+ }
32
+ const existing = merged[key];
33
+ if (existing == null) {
34
+ merged[key] = value;
35
+ continue;
36
+ }
37
+ if (Array.isArray(existing) || Array.isArray(value)) {
38
+ merged[key] = [
39
+ ...arraify(existing !== null && existing !== void 0 ? existing : []),
40
+ ...arraify(value !== null && value !== void 0 ? value : [])
41
+ ];
42
+ continue;
43
+ }
44
+ if (isObject$1(existing) && isObject$1(value)) {
45
+ merged[key] = mergeConfigRecursively(existing, value, rootPath ? `${rootPath}.${key}` : key);
46
+ continue;
47
+ }
48
+ merged[key] = value;
49
+ }
50
+ return merged;
51
+ };
52
+ const mergeConfig = (defaults, overrides) => {
53
+ return mergeConfigRecursively(defaults || {}, overrides || {});
54
+ };
55
+ (_a = config.plugins) == null ? void 0 : _a.push(
56
+ _vite2.default.call(void 0,
57
+ mergeConfig(
58
+ {
59
+ include: [
60
+ /\.[tj]sx?$/,
61
+ /\.vue$/,
62
+ /\.vue\?vue/,
63
+ /\.md$/
64
+ ],
65
+ imports: ["vue", "vue-router"],
66
+ dirs: [],
67
+ vueTemplate: true,
68
+ cache: true
69
+ },
70
+ moduleOptions.autoImportAPIs
71
+ )
72
+ )
73
+ );
74
+ return config;
75
+ }
76
+ async function src_default(moduleOptions) {
13
77
  return {
14
78
  name: "@pinegrow/iles-module",
15
- vite: {
16
- plugins: vitePlugin ? [vitePlugin] : []
17
- },
79
+ vite: await getViteConfiguration(moduleOptions),
18
80
  config(config) {
19
81
  return {
20
82
  vue: {
21
83
  reactivityTransform: false
22
84
  },
23
- ...config,
24
85
  ssg: {
25
86
  beforePageRender: (page) => {
87
+ const doc = _nodehtmlparser2.default.parse(page.rendered, "text/html");
88
+ const addons = [
89
+ {
90
+ name: "pgia",
91
+ resources: [
92
+ {
93
+ parentResource: `public/pgia`,
94
+ injectTo: "head-append",
95
+ tag: "script",
96
+ children: `
97
+ /* 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);}})()`
98
+ },
99
+ {
100
+ parentResource: `public/pgia`,
101
+ injectTo: "body-append",
102
+ tag: "script",
103
+ attrs: { src: "/pgia/lib/index.js" }
104
+ }
105
+ ]
106
+ }
107
+ ];
108
+ addons.forEach((addon) => {
109
+ addon.resources.forEach((resource) => {
110
+ if (!resource.condition) {
111
+ try {
112
+ let parentResourceExists = true;
113
+ if (resource.parentResource) {
114
+ const projectRoot = process.cwd();
115
+ const resourcePath = _path2.default.resolve(projectRoot, resource.parentResource);
116
+ parentResourceExists = parentResourceExists && _fs2.default.existsSync(resourcePath);
117
+ }
118
+ if (parentResourceExists) {
119
+ const attrContent = Object.entries(resource.attrs || {}).reduce(
120
+ (acc, [key, value]) => {
121
+ return `${acc}${key}${value && value !== true ? `="${value}"` : ""}`;
122
+ },
123
+ ""
124
+ );
125
+ let parentNode, sourceNode;
126
+ switch (resource.injectTo) {
127
+ case "head-prepend":
128
+ parentNode = doc.querySelector("head");
129
+ sourceNode = _nodehtmlparser2.default.parse(`<${resource.tag} ${attrContent}>
130
+ ${resource.children || ""}
131
+ </${resource.tag}>`);
132
+ parentNode.childNodes.unshift(sourceNode);
133
+ break;
134
+ case "head-append":
135
+ parentNode = doc.querySelector("head");
136
+ sourceNode = _nodehtmlparser2.default.parse(`<${resource.tag} ${attrContent}>
137
+ ${resource.children || ""}
138
+ </${resource.tag}>`);
139
+ parentNode.appendChild(sourceNode);
140
+ break;
141
+ case "body-prepend":
142
+ parentNode = doc.querySelector("body");
143
+ sourceNode = _nodehtmlparser2.default.parse(`<${resource.tag} ${attrContent}>
144
+ ${resource.children || ""}
145
+ </${resource.tag}>`);
146
+ parentNode.childNodes.unshift(sourceNode);
147
+ break;
148
+ case "body-append":
149
+ parentNode = doc.querySelector("body");
150
+ sourceNode = _nodehtmlparser2.default.parse(`<${resource.tag} ${attrContent}>
151
+ ${resource.children || ""}
152
+ </${resource.tag}>`);
153
+ parentNode.appendChild(sourceNode);
154
+ break;
155
+ }
156
+ }
157
+ } catch (err) {
158
+ }
159
+ }
160
+ });
161
+ });
162
+ page.rendered = doc.outerHTML;
26
163
  }
27
- }
164
+ },
165
+ ...config
28
166
  };
29
167
  }
30
168
  };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  import { IlesModule } from 'iles';
2
+ import AutoImportAPIs from 'unplugin-auto-import/types';
2
3
 
3
4
  /**
4
5
  * An iles module that...
5
6
  */
6
- declare function export_default(moduleOptions: any): IlesModule;
7
+ declare function export_default(moduleOptions: {
8
+ liveDesigner: any;
9
+ autoImportAPIs: ReturnType<typeof AutoImportAPIs>;
10
+ }): IlesModule;
7
11
 
8
12
  export { export_default as default };
package/dist/index.js ADDED
@@ -0,0 +1,172 @@
1
+ // src/index.ts
2
+ import htmlParser from "node-html-parser";
3
+ import path from "path";
4
+ import fs from "fs";
5
+ import autoImportAPIs from "unplugin-auto-import/vite";
6
+ async function getViteConfiguration(moduleOptions) {
7
+ var _a;
8
+ let vitePlugin;
9
+ try {
10
+ const { liveDesigner } = await import("./live-designer-TIVRM3WS.js");
11
+ vitePlugin = liveDesigner(moduleOptions == null ? void 0 : moduleOptions.liveDesigner);
12
+ } catch (err) {
13
+ console.log(err);
14
+ console.log("Pinegrow: @pinegrow/iles-module was unable to load @pinegrow/vite-plugin live-designer!");
15
+ }
16
+ const config = {
17
+ plugins: vitePlugin ? [vitePlugin] : []
18
+ };
19
+ const isObject$1 = (value) => {
20
+ return Object.prototype.toString.call(value) === "[object Object]";
21
+ };
22
+ const arraify = (target) => {
23
+ return Array.isArray(target) ? target : [target];
24
+ };
25
+ const mergeConfigRecursively = (defaults, overrides) => {
26
+ const merged = { ...defaults };
27
+ for (const key in overrides) {
28
+ const value = overrides[key];
29
+ if (value == null) {
30
+ continue;
31
+ }
32
+ const existing = merged[key];
33
+ if (existing == null) {
34
+ merged[key] = value;
35
+ continue;
36
+ }
37
+ if (Array.isArray(existing) || Array.isArray(value)) {
38
+ merged[key] = [
39
+ ...arraify(existing !== null && existing !== void 0 ? existing : []),
40
+ ...arraify(value !== null && value !== void 0 ? value : [])
41
+ ];
42
+ continue;
43
+ }
44
+ if (isObject$1(existing) && isObject$1(value)) {
45
+ merged[key] = mergeConfigRecursively(existing, value, rootPath ? `${rootPath}.${key}` : key);
46
+ continue;
47
+ }
48
+ merged[key] = value;
49
+ }
50
+ return merged;
51
+ };
52
+ const mergeConfig = (defaults, overrides) => {
53
+ return mergeConfigRecursively(defaults || {}, overrides || {});
54
+ };
55
+ (_a = config.plugins) == null ? void 0 : _a.push(
56
+ autoImportAPIs(
57
+ mergeConfig(
58
+ {
59
+ include: [
60
+ /\.[tj]sx?$/,
61
+ /\.vue$/,
62
+ /\.vue\?vue/,
63
+ /\.md$/
64
+ ],
65
+ imports: ["vue", "vue-router"],
66
+ dirs: [],
67
+ vueTemplate: true,
68
+ cache: true
69
+ },
70
+ moduleOptions.autoImportAPIs
71
+ )
72
+ )
73
+ );
74
+ return config;
75
+ }
76
+ async function src_default(moduleOptions) {
77
+ return {
78
+ name: "@pinegrow/iles-module",
79
+ vite: await getViteConfiguration(moduleOptions),
80
+ config(config) {
81
+ return {
82
+ vue: {
83
+ reactivityTransform: false
84
+ },
85
+ ssg: {
86
+ beforePageRender: (page) => {
87
+ const doc = htmlParser.parse(page.rendered, "text/html");
88
+ const addons = [
89
+ {
90
+ name: "pgia",
91
+ resources: [
92
+ {
93
+ parentResource: `public/pgia`,
94
+ injectTo: "head-append",
95
+ tag: "script",
96
+ children: `
97
+ /* 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);}})()`
98
+ },
99
+ {
100
+ parentResource: `public/pgia`,
101
+ injectTo: "body-append",
102
+ tag: "script",
103
+ attrs: { src: "/pgia/lib/index.js" }
104
+ }
105
+ ]
106
+ }
107
+ ];
108
+ addons.forEach((addon) => {
109
+ addon.resources.forEach((resource) => {
110
+ if (!resource.condition) {
111
+ try {
112
+ let parentResourceExists = true;
113
+ if (resource.parentResource) {
114
+ const projectRoot = process.cwd();
115
+ const resourcePath = path.resolve(projectRoot, resource.parentResource);
116
+ parentResourceExists = parentResourceExists && fs.existsSync(resourcePath);
117
+ }
118
+ if (parentResourceExists) {
119
+ const attrContent = Object.entries(resource.attrs || {}).reduce(
120
+ (acc, [key, value]) => {
121
+ return `${acc}${key}${value && value !== true ? `="${value}"` : ""}`;
122
+ },
123
+ ""
124
+ );
125
+ let parentNode, sourceNode;
126
+ switch (resource.injectTo) {
127
+ case "head-prepend":
128
+ parentNode = doc.querySelector("head");
129
+ sourceNode = htmlParser.parse(`<${resource.tag} ${attrContent}>
130
+ ${resource.children || ""}
131
+ </${resource.tag}>`);
132
+ parentNode.childNodes.unshift(sourceNode);
133
+ break;
134
+ case "head-append":
135
+ parentNode = doc.querySelector("head");
136
+ sourceNode = htmlParser.parse(`<${resource.tag} ${attrContent}>
137
+ ${resource.children || ""}
138
+ </${resource.tag}>`);
139
+ parentNode.appendChild(sourceNode);
140
+ break;
141
+ case "body-prepend":
142
+ parentNode = doc.querySelector("body");
143
+ sourceNode = htmlParser.parse(`<${resource.tag} ${attrContent}>
144
+ ${resource.children || ""}
145
+ </${resource.tag}>`);
146
+ parentNode.childNodes.unshift(sourceNode);
147
+ break;
148
+ case "body-append":
149
+ parentNode = doc.querySelector("body");
150
+ sourceNode = htmlParser.parse(`<${resource.tag} ${attrContent}>
151
+ ${resource.children || ""}
152
+ </${resource.tag}>`);
153
+ parentNode.appendChild(sourceNode);
154
+ break;
155
+ }
156
+ }
157
+ } catch (err) {
158
+ }
159
+ }
160
+ });
161
+ });
162
+ page.rendered = doc.outerHTML;
163
+ }
164
+ },
165
+ ...config
166
+ };
167
+ }
168
+ };
169
+ }
170
+ export {
171
+ src_default as default
172
+ };
@@ -4,3 +4,4 @@ var liveDesigner = _viteplugin2.default.liveDesigner;
4
4
 
5
5
 
6
6
  exports.liveDesigner = liveDesigner;
7
+ /*! import { liveDesigner } from '@pinegrow/vite-plugin/dev' */
@@ -0,0 +1,7 @@
1
+ // src/live-designer.mjs
2
+ import pkg from "@pinegrow/vite-plugin";
3
+ var liveDesigner = pkg.liveDesigner;
4
+ export {
5
+ liveDesigner
6
+ };
7
+ /*! import { liveDesigner } from '@pinegrow/vite-plugin/dev' */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinegrow/iles-module",
3
- "version": "0.0.1-beta.3",
3
+ "version": "3.0.0-beta.101",
4
4
  "description": "Pinegrow Iles Module",
5
5
  "author": "Pinegrow (http://pinegrow.com/)",
6
6
  "license": "MIT",
@@ -8,13 +8,15 @@
8
8
  "files": [
9
9
  "dist"
10
10
  ],
11
- "types": "dist/index.d.ts",
11
+ "types": "./dist/index.d.ts",
12
+ "main": "./dist/index.cjs",
13
+ "module": "./dist/index.cjs",
12
14
  "exports": {
15
+ "./package.json": "./package.json",
13
16
  ".": {
14
- "import": "./src/index.mjs",
17
+ "import": "./dist/index.js",
15
18
  "require": "./dist/index.cjs"
16
- },
17
- "./package.json": "./package.json"
19
+ }
18
20
  },
19
21
  "keywords": [
20
22
  "pinegrow",
@@ -28,10 +30,17 @@
28
30
  "publish-beta": "npm run increment-beta-version && npm publish",
29
31
  "increment-beta-version": "npm version prerelease --preid=beta"
30
32
  },
33
+ "dependencies": {
34
+ "@pinegrow/vite-plugin": "3.0.0-beta.101",
35
+ "node-html-parser": "^6.1.5",
36
+ "unplugin-auto-import": "^0.15.2"
37
+ },
31
38
  "devDependencies": {
32
39
  "iles": "^0.5",
33
40
  "tsup": "^5.5.0",
34
- "typescript": "^4.4.4",
35
- "node-html-parser": "^6.1.5"
41
+ "typescript": "^4.4.4"
42
+ },
43
+ "peerDependencies": {
44
+ "iles": "^0.5"
36
45
  }
37
46
  }
File without changes