@pinegrow/astro-module 3.0.8 → 3.0.13
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 +1 -123
- package/dist/index.js +0 -122
- package/package.json +5 -3
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
|
|
2
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }// src/index.ts
|
|
3
2
|
async function getViteConfiguration(moduleOptions) {
|
|
4
|
-
var _a, _b, _c;
|
|
5
3
|
let vitePlugin;
|
|
6
4
|
try {
|
|
7
5
|
const { liveDesigner } = await Promise.resolve().then(() => _interopRequireWildcard(require("./live-designer-PEHWBCFL.cjs")));
|
|
8
6
|
vitePlugin = liveDesigner({
|
|
9
|
-
tailwindcss: {
|
|
10
|
-
configPath: "tailwind.config.js",
|
|
11
|
-
cssPath: "@/assets/css/tailwind.css"
|
|
12
|
-
},
|
|
13
7
|
...(moduleOptions == null ? void 0 : moduleOptions.liveDesigner) || {}
|
|
14
8
|
});
|
|
15
9
|
} catch (err) {
|
|
@@ -19,64 +13,6 @@ async function getViteConfiguration(moduleOptions) {
|
|
|
19
13
|
let config = {
|
|
20
14
|
plugins: vitePlugin ? [vitePlugin] : []
|
|
21
15
|
};
|
|
22
|
-
const isObject$1 = (value) => {
|
|
23
|
-
return Object.prototype.toString.call(value) === "[object Object]";
|
|
24
|
-
};
|
|
25
|
-
const arraify = (target) => {
|
|
26
|
-
return Array.isArray(target) ? target : [target];
|
|
27
|
-
};
|
|
28
|
-
const mergeConfigRecursively = (defaults, overrides) => {
|
|
29
|
-
const merged = { ...defaults };
|
|
30
|
-
for (const key in overrides) {
|
|
31
|
-
const value = overrides[key];
|
|
32
|
-
if (value == null) {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
const existing = merged[key];
|
|
36
|
-
if (existing == null) {
|
|
37
|
-
merged[key] = value;
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
if (Array.isArray(existing) || Array.isArray(value)) {
|
|
41
|
-
merged[key] = [
|
|
42
|
-
...arraify(existing !== null && existing !== void 0 ? existing : []),
|
|
43
|
-
...arraify(value !== null && value !== void 0 ? value : [])
|
|
44
|
-
];
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
if (isObject$1(existing) && isObject$1(value)) {
|
|
48
|
-
merged[key] = mergeConfigRecursively(existing, value, rootPath ? `${rootPath}.${key}` : key);
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
merged[key] = value;
|
|
52
|
-
}
|
|
53
|
-
return merged;
|
|
54
|
-
};
|
|
55
|
-
const mergeConfig = (defaults, overrides) => {
|
|
56
|
-
return mergeConfigRecursively(defaults || {}, overrides || {});
|
|
57
|
-
};
|
|
58
|
-
const ignoreList = [
|
|
59
|
-
.../* @__PURE__ */ new Set([...((_b = (_a = config == null ? void 0 : config.server) == null ? void 0 : _a.watch) == null ? void 0 : _b.ignored) || [], "**/_pgbackup/**", "**/_pginfo/**", "**/pinegrow.json"])
|
|
60
|
-
];
|
|
61
|
-
config = mergeConfig(config, {
|
|
62
|
-
server: {
|
|
63
|
-
watch: {
|
|
64
|
-
ignored: ignoreList
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
const alias = (_c = config == null ? void 0 : config.resolve) == null ? void 0 : _c.alias;
|
|
69
|
-
if (!alias) {
|
|
70
|
-
config = mergeConfig(config, {
|
|
71
|
-
resolve: {
|
|
72
|
-
alias: {
|
|
73
|
-
"@": _path2.default.resolve(config.root || process.cwd(), "./src"),
|
|
74
|
-
"~": _path2.default.resolve(config.root || process.cwd(), "./src"),
|
|
75
|
-
"~~": _path2.default.resolve(config.root || process.cwd(), "./")
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
16
|
return config;
|
|
81
17
|
}
|
|
82
18
|
function createIntegration(moduleOptions) {
|
|
@@ -87,54 +23,6 @@ function createIntegration(moduleOptions) {
|
|
|
87
23
|
updateConfig({
|
|
88
24
|
vite: await getViteConfiguration(moduleOptions)
|
|
89
25
|
});
|
|
90
|
-
const addons = [
|
|
91
|
-
{
|
|
92
|
-
name: "pgia",
|
|
93
|
-
resources: [
|
|
94
|
-
{
|
|
95
|
-
parentResource: "src/assets/pgia",
|
|
96
|
-
injectTo: "head-inline",
|
|
97
|
-
tag: "script",
|
|
98
|
-
children: `
|
|
99
|
-
/* 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);}})()`
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
parentResource: "src/assets/pgia",
|
|
103
|
-
injectTo: "page",
|
|
104
|
-
tag: "script",
|
|
105
|
-
children: 'import "@/assets/pgia/lib/index.js"'
|
|
106
|
-
}
|
|
107
|
-
]
|
|
108
|
-
}
|
|
109
|
-
];
|
|
110
|
-
const injects = [];
|
|
111
|
-
addons.forEach((addon) => {
|
|
112
|
-
addon.resources.forEach((resource) => {
|
|
113
|
-
if (!resource.condition) {
|
|
114
|
-
try {
|
|
115
|
-
let parentResourceExists = true;
|
|
116
|
-
if (resource.parentResource) {
|
|
117
|
-
const projectRoot = process.cwd();
|
|
118
|
-
const resourcePath = _path2.default.resolve(projectRoot, resource.parentResource);
|
|
119
|
-
parentResourceExists = parentResourceExists && fs.existsSync(resourcePath);
|
|
120
|
-
}
|
|
121
|
-
if (parentResourceExists) {
|
|
122
|
-
injects.push({
|
|
123
|
-
injectTo: resource.injectTo,
|
|
124
|
-
tag: resource.tag,
|
|
125
|
-
attrs: resource.attrs,
|
|
126
|
-
children: resource.children
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
} catch (err) {
|
|
130
|
-
console.log(err);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
injects.filter((inject) => inject.tag === "script").forEach((inject) => {
|
|
136
|
-
injectScript(inject.injectTo, inject.children);
|
|
137
|
-
});
|
|
138
26
|
},
|
|
139
27
|
"astro:server:setup": ({ server }) => {
|
|
140
28
|
const liveDesignerPluginIndex = server.config.plugins.findIndex(
|
|
@@ -144,16 +32,6 @@ function createIntegration(moduleOptions) {
|
|
|
144
32
|
server.config.plugins.splice(liveDesignerPluginIndex, 1);
|
|
145
33
|
const astroBuildIndex = server.config.plugins.findIndex((plugin) => plugin.name === "astro:build");
|
|
146
34
|
server.config.plugins.splice(astroBuildIndex, 0, liveDesignerPlugin);
|
|
147
|
-
const alias = server.config.resolve.alias.find((alias2) => alias2.find === "@");
|
|
148
|
-
const aliases = server.config.resolve.alias.filter((alias2) => alias2.find !== "@");
|
|
149
|
-
server.config.resolve.alias = [...aliases];
|
|
150
|
-
if (alias) {
|
|
151
|
-
server.config.resolve.alias.push(alias);
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
"astro:build:setup": ({ vite, pages, target }) => {
|
|
155
|
-
},
|
|
156
|
-
"astro:build:done": ({ dir, routes }) => {
|
|
157
35
|
}
|
|
158
36
|
}
|
|
159
37
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import path from "path";
|
|
3
2
|
async function getViteConfiguration(moduleOptions) {
|
|
4
|
-
var _a, _b, _c;
|
|
5
3
|
let vitePlugin;
|
|
6
4
|
try {
|
|
7
5
|
const { liveDesigner } = await import("./live-designer-TIVRM3WS.js");
|
|
8
6
|
vitePlugin = liveDesigner({
|
|
9
|
-
tailwindcss: {
|
|
10
|
-
configPath: "tailwind.config.js",
|
|
11
|
-
cssPath: "@/assets/css/tailwind.css"
|
|
12
|
-
},
|
|
13
7
|
...(moduleOptions == null ? void 0 : moduleOptions.liveDesigner) || {}
|
|
14
8
|
});
|
|
15
9
|
} catch (err) {
|
|
@@ -19,64 +13,6 @@ async function getViteConfiguration(moduleOptions) {
|
|
|
19
13
|
let config = {
|
|
20
14
|
plugins: vitePlugin ? [vitePlugin] : []
|
|
21
15
|
};
|
|
22
|
-
const isObject$1 = (value) => {
|
|
23
|
-
return Object.prototype.toString.call(value) === "[object Object]";
|
|
24
|
-
};
|
|
25
|
-
const arraify = (target) => {
|
|
26
|
-
return Array.isArray(target) ? target : [target];
|
|
27
|
-
};
|
|
28
|
-
const mergeConfigRecursively = (defaults, overrides) => {
|
|
29
|
-
const merged = { ...defaults };
|
|
30
|
-
for (const key in overrides) {
|
|
31
|
-
const value = overrides[key];
|
|
32
|
-
if (value == null) {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
const existing = merged[key];
|
|
36
|
-
if (existing == null) {
|
|
37
|
-
merged[key] = value;
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
if (Array.isArray(existing) || Array.isArray(value)) {
|
|
41
|
-
merged[key] = [
|
|
42
|
-
...arraify(existing !== null && existing !== void 0 ? existing : []),
|
|
43
|
-
...arraify(value !== null && value !== void 0 ? value : [])
|
|
44
|
-
];
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
if (isObject$1(existing) && isObject$1(value)) {
|
|
48
|
-
merged[key] = mergeConfigRecursively(existing, value, rootPath ? `${rootPath}.${key}` : key);
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
merged[key] = value;
|
|
52
|
-
}
|
|
53
|
-
return merged;
|
|
54
|
-
};
|
|
55
|
-
const mergeConfig = (defaults, overrides) => {
|
|
56
|
-
return mergeConfigRecursively(defaults || {}, overrides || {});
|
|
57
|
-
};
|
|
58
|
-
const ignoreList = [
|
|
59
|
-
.../* @__PURE__ */ new Set([...((_b = (_a = config == null ? void 0 : config.server) == null ? void 0 : _a.watch) == null ? void 0 : _b.ignored) || [], "**/_pgbackup/**", "**/_pginfo/**", "**/pinegrow.json"])
|
|
60
|
-
];
|
|
61
|
-
config = mergeConfig(config, {
|
|
62
|
-
server: {
|
|
63
|
-
watch: {
|
|
64
|
-
ignored: ignoreList
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
const alias = (_c = config == null ? void 0 : config.resolve) == null ? void 0 : _c.alias;
|
|
69
|
-
if (!alias) {
|
|
70
|
-
config = mergeConfig(config, {
|
|
71
|
-
resolve: {
|
|
72
|
-
alias: {
|
|
73
|
-
"@": path.resolve(config.root || process.cwd(), "./src"),
|
|
74
|
-
"~": path.resolve(config.root || process.cwd(), "./src"),
|
|
75
|
-
"~~": path.resolve(config.root || process.cwd(), "./")
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
16
|
return config;
|
|
81
17
|
}
|
|
82
18
|
function createIntegration(moduleOptions) {
|
|
@@ -87,54 +23,6 @@ function createIntegration(moduleOptions) {
|
|
|
87
23
|
updateConfig({
|
|
88
24
|
vite: await getViteConfiguration(moduleOptions)
|
|
89
25
|
});
|
|
90
|
-
const addons = [
|
|
91
|
-
{
|
|
92
|
-
name: "pgia",
|
|
93
|
-
resources: [
|
|
94
|
-
{
|
|
95
|
-
parentResource: "src/assets/pgia",
|
|
96
|
-
injectTo: "head-inline",
|
|
97
|
-
tag: "script",
|
|
98
|
-
children: `
|
|
99
|
-
/* 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);}})()`
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
parentResource: "src/assets/pgia",
|
|
103
|
-
injectTo: "page",
|
|
104
|
-
tag: "script",
|
|
105
|
-
children: 'import "@/assets/pgia/lib/index.js"'
|
|
106
|
-
}
|
|
107
|
-
]
|
|
108
|
-
}
|
|
109
|
-
];
|
|
110
|
-
const injects = [];
|
|
111
|
-
addons.forEach((addon) => {
|
|
112
|
-
addon.resources.forEach((resource) => {
|
|
113
|
-
if (!resource.condition) {
|
|
114
|
-
try {
|
|
115
|
-
let parentResourceExists = true;
|
|
116
|
-
if (resource.parentResource) {
|
|
117
|
-
const projectRoot = process.cwd();
|
|
118
|
-
const resourcePath = path.resolve(projectRoot, resource.parentResource);
|
|
119
|
-
parentResourceExists = parentResourceExists && fs.existsSync(resourcePath);
|
|
120
|
-
}
|
|
121
|
-
if (parentResourceExists) {
|
|
122
|
-
injects.push({
|
|
123
|
-
injectTo: resource.injectTo,
|
|
124
|
-
tag: resource.tag,
|
|
125
|
-
attrs: resource.attrs,
|
|
126
|
-
children: resource.children
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
} catch (err) {
|
|
130
|
-
console.log(err);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
injects.filter((inject) => inject.tag === "script").forEach((inject) => {
|
|
136
|
-
injectScript(inject.injectTo, inject.children);
|
|
137
|
-
});
|
|
138
26
|
},
|
|
139
27
|
"astro:server:setup": ({ server }) => {
|
|
140
28
|
const liveDesignerPluginIndex = server.config.plugins.findIndex(
|
|
@@ -144,16 +32,6 @@ function createIntegration(moduleOptions) {
|
|
|
144
32
|
server.config.plugins.splice(liveDesignerPluginIndex, 1);
|
|
145
33
|
const astroBuildIndex = server.config.plugins.findIndex((plugin) => plugin.name === "astro:build");
|
|
146
34
|
server.config.plugins.splice(astroBuildIndex, 0, liveDesignerPlugin);
|
|
147
|
-
const alias = server.config.resolve.alias.find((alias2) => alias2.find === "@");
|
|
148
|
-
const aliases = server.config.resolve.alias.filter((alias2) => alias2.find !== "@");
|
|
149
|
-
server.config.resolve.alias = [...aliases];
|
|
150
|
-
if (alias) {
|
|
151
|
-
server.config.resolve.alias.push(alias);
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
"astro:build:setup": ({ vite, pages, target }) => {
|
|
155
|
-
},
|
|
156
|
-
"astro:build:done": ({ dir, routes }) => {
|
|
157
35
|
}
|
|
158
36
|
}
|
|
159
37
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pinegrow/astro-module",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.13",
|
|
4
4
|
"description": "Pinegrow Astro Module",
|
|
5
5
|
"author": "Pinegrow (http://pinegrow.com/)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,10 +33,12 @@
|
|
|
33
33
|
"prepublishOnly": "npm run build",
|
|
34
34
|
"release": "npx bumpp --commit --tag --push && npm publish --access public",
|
|
35
35
|
"publish-beta": "npm run increment-beta-version && npm publish",
|
|
36
|
-
"increment-beta-version": "npm version prerelease --preid=beta"
|
|
36
|
+
"increment-beta-version": "npm version prerelease --preid=beta",
|
|
37
|
+
"publish-patch": "npm publish",
|
|
38
|
+
"increment-version": "npm version patch"
|
|
37
39
|
},
|
|
38
40
|
"dependencies": {
|
|
39
|
-
"@pinegrow/vite-plugin": "3.0.
|
|
41
|
+
"@pinegrow/vite-plugin": "3.0.13"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
44
|
"astro": "^2.1.5",
|