@pinegrow/iles-module 3.0.0-beta.110 → 3.0.0-beta.111
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/dist/index.cjs +79 -86
- package/dist/index.js +79 -86
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -95,96 +95,89 @@ async function src_default(moduleOptions) {
|
|
|
95
95
|
vite: await getViteConfiguration(moduleOptions),
|
|
96
96
|
// Just like in Vite plugins you can use this hook to extend the user config
|
|
97
97
|
config(config) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const addons = [
|
|
98
|
+
config.vue.reactivityTransform = false;
|
|
99
|
+
config.ssg.beforePageRender = (page) => {
|
|
100
|
+
const doc = _nodehtmlparser2.default.parse(page.rendered, "text/html");
|
|
101
|
+
const addons = [
|
|
102
|
+
{
|
|
103
|
+
name: "pgia",
|
|
104
|
+
resources: [
|
|
106
105
|
{
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
injectTo: "body-append",
|
|
124
|
-
tag: "script",
|
|
125
|
-
attrs: { src: "/pgia/lib/index.js" }
|
|
126
|
-
}
|
|
127
|
-
]
|
|
106
|
+
// condition: 'interactions',
|
|
107
|
+
parentResource: `public/pgia`,
|
|
108
|
+
// relative to project root, must exists
|
|
109
|
+
// source: `<script src="pgia/index.js"></script>`,
|
|
110
|
+
injectTo: "head-append",
|
|
111
|
+
tag: "script",
|
|
112
|
+
children: `
|
|
113
|
+
/* 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);}})()`
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
// condition: 'interactions',
|
|
117
|
+
parentResource: `public/pgia`,
|
|
118
|
+
// relative to project root, must exists
|
|
119
|
+
injectTo: "body-append",
|
|
120
|
+
tag: "script",
|
|
121
|
+
attrs: { src: "/pgia/lib/index.js" }
|
|
128
122
|
}
|
|
129
|
-
]
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
} catch (err) {
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
];
|
|
126
|
+
addons.forEach((addon) => {
|
|
127
|
+
addon.resources.forEach((resource) => {
|
|
128
|
+
if (!resource.condition) {
|
|
129
|
+
try {
|
|
130
|
+
let parentResourceExists = true;
|
|
131
|
+
if (resource.parentResource) {
|
|
132
|
+
const projectRoot = process.cwd();
|
|
133
|
+
const resourcePath = _path2.default.resolve(projectRoot, resource.parentResource);
|
|
134
|
+
parentResourceExists = parentResourceExists && _fs2.default.existsSync(resourcePath);
|
|
135
|
+
}
|
|
136
|
+
if (parentResourceExists) {
|
|
137
|
+
const attrContent = Object.entries(resource.attrs || {}).reduce(
|
|
138
|
+
(acc, [key, value]) => {
|
|
139
|
+
return `${acc}${key}${value && value !== true ? `="${value}"` : ""}`;
|
|
140
|
+
},
|
|
141
|
+
""
|
|
142
|
+
);
|
|
143
|
+
let parentNode, sourceNode;
|
|
144
|
+
switch (resource.injectTo) {
|
|
145
|
+
case "head-prepend":
|
|
146
|
+
parentNode = doc.querySelector("head");
|
|
147
|
+
sourceNode = _nodehtmlparser2.default.parse(`<${resource.tag} ${attrContent}>
|
|
148
|
+
${resource.children || ""}
|
|
149
|
+
</${resource.tag}>`);
|
|
150
|
+
parentNode.childNodes.unshift(sourceNode);
|
|
151
|
+
break;
|
|
152
|
+
case "head-append":
|
|
153
|
+
parentNode = doc.querySelector("head");
|
|
154
|
+
sourceNode = _nodehtmlparser2.default.parse(`<${resource.tag} ${attrContent}>
|
|
155
|
+
${resource.children || ""}
|
|
156
|
+
</${resource.tag}>`);
|
|
157
|
+
parentNode.appendChild(sourceNode);
|
|
158
|
+
break;
|
|
159
|
+
case "body-prepend":
|
|
160
|
+
parentNode = doc.querySelector("body");
|
|
161
|
+
sourceNode = _nodehtmlparser2.default.parse(`<${resource.tag} ${attrContent}>
|
|
162
|
+
${resource.children || ""}
|
|
163
|
+
</${resource.tag}>`);
|
|
164
|
+
parentNode.childNodes.unshift(sourceNode);
|
|
165
|
+
break;
|
|
166
|
+
case "body-append":
|
|
167
|
+
parentNode = doc.querySelector("body");
|
|
168
|
+
sourceNode = _nodehtmlparser2.default.parse(`<${resource.tag} ${attrContent}>
|
|
169
|
+
${resource.children || ""}
|
|
170
|
+
</${resource.tag}>`);
|
|
171
|
+
parentNode.appendChild(sourceNode);
|
|
172
|
+
break;
|
|
180
173
|
}
|
|
181
174
|
}
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
175
|
+
} catch (err) {
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
page.rendered = doc.outerHTML;
|
|
188
181
|
};
|
|
189
182
|
}
|
|
190
183
|
};
|
package/dist/index.js
CHANGED
|
@@ -95,96 +95,89 @@ async function src_default(moduleOptions) {
|
|
|
95
95
|
vite: await getViteConfiguration(moduleOptions),
|
|
96
96
|
// Just like in Vite plugins you can use this hook to extend the user config
|
|
97
97
|
config(config) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const addons = [
|
|
98
|
+
config.vue.reactivityTransform = false;
|
|
99
|
+
config.ssg.beforePageRender = (page) => {
|
|
100
|
+
const doc = htmlParser.parse(page.rendered, "text/html");
|
|
101
|
+
const addons = [
|
|
102
|
+
{
|
|
103
|
+
name: "pgia",
|
|
104
|
+
resources: [
|
|
106
105
|
{
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
injectTo: "body-append",
|
|
124
|
-
tag: "script",
|
|
125
|
-
attrs: { src: "/pgia/lib/index.js" }
|
|
126
|
-
}
|
|
127
|
-
]
|
|
106
|
+
// condition: 'interactions',
|
|
107
|
+
parentResource: `public/pgia`,
|
|
108
|
+
// relative to project root, must exists
|
|
109
|
+
// source: `<script src="pgia/index.js"></script>`,
|
|
110
|
+
injectTo: "head-append",
|
|
111
|
+
tag: "script",
|
|
112
|
+
children: `
|
|
113
|
+
/* 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);}})()`
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
// condition: 'interactions',
|
|
117
|
+
parentResource: `public/pgia`,
|
|
118
|
+
// relative to project root, must exists
|
|
119
|
+
injectTo: "body-append",
|
|
120
|
+
tag: "script",
|
|
121
|
+
attrs: { src: "/pgia/lib/index.js" }
|
|
128
122
|
}
|
|
129
|
-
]
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
} catch (err) {
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
];
|
|
126
|
+
addons.forEach((addon) => {
|
|
127
|
+
addon.resources.forEach((resource) => {
|
|
128
|
+
if (!resource.condition) {
|
|
129
|
+
try {
|
|
130
|
+
let parentResourceExists = true;
|
|
131
|
+
if (resource.parentResource) {
|
|
132
|
+
const projectRoot = process.cwd();
|
|
133
|
+
const resourcePath = path.resolve(projectRoot, resource.parentResource);
|
|
134
|
+
parentResourceExists = parentResourceExists && fs.existsSync(resourcePath);
|
|
135
|
+
}
|
|
136
|
+
if (parentResourceExists) {
|
|
137
|
+
const attrContent = Object.entries(resource.attrs || {}).reduce(
|
|
138
|
+
(acc, [key, value]) => {
|
|
139
|
+
return `${acc}${key}${value && value !== true ? `="${value}"` : ""}`;
|
|
140
|
+
},
|
|
141
|
+
""
|
|
142
|
+
);
|
|
143
|
+
let parentNode, sourceNode;
|
|
144
|
+
switch (resource.injectTo) {
|
|
145
|
+
case "head-prepend":
|
|
146
|
+
parentNode = doc.querySelector("head");
|
|
147
|
+
sourceNode = htmlParser.parse(`<${resource.tag} ${attrContent}>
|
|
148
|
+
${resource.children || ""}
|
|
149
|
+
</${resource.tag}>`);
|
|
150
|
+
parentNode.childNodes.unshift(sourceNode);
|
|
151
|
+
break;
|
|
152
|
+
case "head-append":
|
|
153
|
+
parentNode = doc.querySelector("head");
|
|
154
|
+
sourceNode = htmlParser.parse(`<${resource.tag} ${attrContent}>
|
|
155
|
+
${resource.children || ""}
|
|
156
|
+
</${resource.tag}>`);
|
|
157
|
+
parentNode.appendChild(sourceNode);
|
|
158
|
+
break;
|
|
159
|
+
case "body-prepend":
|
|
160
|
+
parentNode = doc.querySelector("body");
|
|
161
|
+
sourceNode = htmlParser.parse(`<${resource.tag} ${attrContent}>
|
|
162
|
+
${resource.children || ""}
|
|
163
|
+
</${resource.tag}>`);
|
|
164
|
+
parentNode.childNodes.unshift(sourceNode);
|
|
165
|
+
break;
|
|
166
|
+
case "body-append":
|
|
167
|
+
parentNode = doc.querySelector("body");
|
|
168
|
+
sourceNode = htmlParser.parse(`<${resource.tag} ${attrContent}>
|
|
169
|
+
${resource.children || ""}
|
|
170
|
+
</${resource.tag}>`);
|
|
171
|
+
parentNode.appendChild(sourceNode);
|
|
172
|
+
break;
|
|
180
173
|
}
|
|
181
174
|
}
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
175
|
+
} catch (err) {
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
page.rendered = doc.outerHTML;
|
|
188
181
|
};
|
|
189
182
|
}
|
|
190
183
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pinegrow/iles-module",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.111",
|
|
4
4
|
"description": "Pinegrow Iles Module",
|
|
5
5
|
"author": "Pinegrow (http://pinegrow.com/)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"increment-beta-version": "npm version prerelease --preid=beta"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@pinegrow/vite-plugin": "3.0.0-beta.
|
|
34
|
+
"@pinegrow/vite-plugin": "3.0.0-beta.111",
|
|
35
35
|
"node-html-parser": "^6.1.5",
|
|
36
36
|
"unplugin-auto-import": "^0.15.2"
|
|
37
37
|
},
|