@bagelink/blox 1.13.5 → 1.14.7
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 +21 -0
- package/dist/CmsPageView.vue.d.ts.map +1 -1
- package/dist/PreviewApp-BDMfuAiu.cjs +4 -0
- package/dist/PreviewApp-MdZQEVkN.js +4 -0
- package/dist/PreviewApp.vue.d.ts.map +1 -1
- package/dist/PreviewApp.vue_vue_type_style_index_0_lang-BG9Fvfdw.cjs +187 -0
- package/dist/PreviewApp.vue_vue_type_style_index_0_lang-Bc4Ac4WN.js +188 -0
- package/dist/PreviewRenderer.d.ts.map +1 -1
- package/dist/bridge.d.ts +5 -0
- package/dist/bridge.d.ts.map +1 -1
- package/dist/core-CgtYpQbn.js +466 -0
- package/dist/core-DhrL5TMI.cjs +465 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/createBloxApp.d.ts +107 -0
- package/dist/createBloxApp.d.ts.map +1 -0
- package/dist/defineBlock.d.ts +23 -4
- package/dist/defineBlock.d.ts.map +1 -1
- package/dist/index.cjs +87 -604
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +86 -602
- package/dist/{prerender-oMLxrKGs.js → prerender-CJ22vZ1T.js} +12 -10
- package/dist/{prerender-CjJwDXkC.cjs → prerender-LqPEzho3.cjs} +8 -6
- package/dist/schema.d.ts +6 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/ssg/cli.cjs +2 -2
- package/dist/ssg/cli.mjs +2 -2
- package/dist/ssg/client.cjs +9 -7
- package/dist/ssg/client.d.ts +1 -1
- package/dist/ssg/client.d.ts.map +1 -1
- package/dist/ssg/client.mjs +3 -1
- package/dist/ssg/collection-cache.d.ts +1 -1
- package/dist/ssg/constants.d.ts +1 -1
- package/dist/ssg/constants.d.ts.map +1 -1
- package/dist/ssg/createSSREntry.d.ts +73 -0
- package/dist/ssg/createSSREntry.d.ts.map +1 -0
- package/dist/ssg/index.cjs +116 -8
- package/dist/ssg/index.d.ts +2 -0
- package/dist/ssg/index.d.ts.map +1 -1
- package/dist/ssg/index.mjs +94 -7
- package/dist/ssg/prerender.d.ts.map +1 -1
- package/dist/ssg/render-resolved-page.d.ts +1 -1
- package/dist/ssg/render-resolved-page.d.ts.map +1 -1
- package/dist/style.css +5 -46
- package/dist/vite-plugin.cjs +143 -3
- package/dist/vite-plugin.d.ts +22 -21
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.mjs +143 -3
- package/package.json +128 -126
- package/dist/PreviewApp-BZNzZkit.js +0 -4
- package/dist/PreviewApp-C1WvJWI4.cjs +0 -4
- package/dist/constants-BjitNk-W.js +0 -8
- package/dist/constants-CFB_pMvT.cjs +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prerender.d.ts","sourceRoot":"","sources":["../../src/ssg/prerender.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prerender.d.ts","sourceRoot":"","sources":["../../src/ssg/prerender.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAc1C,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,CAAA;AAEhE,MAAM,WAAW,gBAAgB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAA;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IACrB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IAC5B,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kDAAkD;IAClD,SAAS,CAAC,EAAE,aAAa,EAAE,CAAA;IAC3B,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAA;CACvC;AAED,MAAM,WAAW,aAAa;IAC7B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,CAAA;IACzC,QAAQ,EAAE,MAAM,CAAA;IAChB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IAC5B,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAA;CACvC;AAED,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;CACf;AAMD,MAAM,WAAW,eAAe;IAC/B,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IAC7D,eAAe,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,SAAS,CAAC,EAC/B,IAAoB,EACpB,YAA4B,EAC5B,WAA0C,EAC1C,KAAU,EACV,KAAY,EACZ,YAAiB,EACjB,QAAgB,EAChB,QAAe,EACf,IAAY,EACZ,OAAc,EACd,SAAc,EACd,SAAc,EACd,WAAgB,GAChB,GAAE,gBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CA4HlD"}
|
|
@@ -26,7 +26,7 @@ export declare function renderBloxSsgPage<TApp>(options: {
|
|
|
26
26
|
stateWindowKey?: string;
|
|
27
27
|
/** Website settings for SEO tags. If omitted, only state script is emitted. */
|
|
28
28
|
website?: WebsiteRead | null;
|
|
29
|
-
/** Resolved website ID — embedded so client skips GET /
|
|
29
|
+
/** Resolved website ID — embedded so client skips GET /blox/websites. */
|
|
30
30
|
websiteId?: string;
|
|
31
31
|
/** Pre-fetched datastore collections — embedded for zero-fetch hydration. */
|
|
32
32
|
collections?: Record<string, unknown[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-resolved-page.d.ts","sourceRoot":"","sources":["../../src/ssg/render-resolved-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAK/C,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACpC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE;IACtD,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,OAAO,GAAG,IAAI,CAAA;IAC5B,cAAc,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IAC9C,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK;QAAE,GAAG,EAAE,IAAI,CAAC;QAAC,MAAM,EAAE,iBAAiB,CAAA;KAAE,CAAA;IAC1E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IAC5B,
|
|
1
|
+
{"version":3,"file":"render-resolved-page.d.ts","sourceRoot":"","sources":["../../src/ssg/render-resolved-page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAK/C,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACpC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE;IACtD,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,OAAO,GAAG,IAAI,CAAA;IAC5B,cAAc,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IAC9C,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK;QAAE,GAAG,EAAE,IAAI,CAAC;QAAC,MAAM,EAAE,iBAAiB,CAAA;KAAE,CAAA;IAC1E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;IAC5B,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAA;CACvC,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA2D/D"}
|
package/dist/style.css
CHANGED
|
@@ -10,9 +10,11 @@
|
|
|
10
10
|
animation: blox-nav-slide 1s ease-in-out infinite;
|
|
11
11
|
}
|
|
12
12
|
@keyframes blox-nav-slide {
|
|
13
|
-
0% {
|
|
13
|
+
0% {
|
|
14
|
+
transform: translateX(-100%);
|
|
14
15
|
}
|
|
15
|
-
100% {
|
|
16
|
+
100% {
|
|
17
|
+
transform: translateX(100%);
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -22,48 +24,5 @@
|
|
|
22
24
|
body {
|
|
23
25
|
margin: 0;
|
|
24
26
|
}
|
|
25
|
-
.blox-block-wrapper {
|
|
26
|
-
position: relative;
|
|
27
|
-
cursor: pointer;
|
|
28
|
-
}
|
|
29
|
-
.blox-block-overlay {
|
|
30
|
-
position: absolute;
|
|
31
|
-
inset: 0;
|
|
32
|
-
z-index: 10;
|
|
33
|
-
pointer-events: auto;
|
|
34
|
-
transition:
|
|
35
|
-
box-shadow 0.12s,
|
|
36
|
-
background 0.12s;
|
|
37
|
-
}
|
|
38
|
-
.blox-block--hovered .blox-block-overlay {
|
|
39
|
-
box-shadow: inset 0 0 0 2px rgba(99, 102, 241, 0.5);
|
|
40
|
-
background: rgba(99, 102, 241, 0.04);
|
|
41
|
-
}
|
|
42
|
-
.blox-block--selected .blox-block-overlay {
|
|
43
|
-
box-shadow: inset 0 0 0 3px #6366f1;
|
|
44
|
-
background: rgba(99, 102, 241, 0.06);
|
|
45
|
-
}
|
|
46
27
|
|
|
47
|
-
/*
|
|
48
|
-
.blox-block-label {
|
|
49
|
-
position: absolute;
|
|
50
|
-
top: 0;
|
|
51
|
-
left: 0;
|
|
52
|
-
z-index: 20;
|
|
53
|
-
padding: 2px 8px;
|
|
54
|
-
font-size: 11px;
|
|
55
|
-
font-family: system-ui, sans-serif;
|
|
56
|
-
font-weight: 600;
|
|
57
|
-
line-height: 20px;
|
|
58
|
-
letter-spacing: 0.02em;
|
|
59
|
-
text-transform: uppercase;
|
|
60
|
-
color: #6366f1;
|
|
61
|
-
background: rgba(99, 102, 241, 0.1);
|
|
62
|
-
border-bottom-right-radius: 4px;
|
|
63
|
-
pointer-events: none;
|
|
64
|
-
white-space: nowrap;
|
|
65
|
-
}
|
|
66
|
-
.blox-block-label--selected {
|
|
67
|
-
color: #fff;
|
|
68
|
-
background: #6366f1;
|
|
69
|
-
}
|
|
28
|
+
/* Block selection styles are applied via inline styles in PreviewRenderer */
|
package/dist/vite-plugin.cjs
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const node_module = require("node:module");
|
|
4
|
+
const path = require("node:path");
|
|
5
|
+
const process = require("node:process");
|
|
3
6
|
var comma = ",".charCodeAt(0);
|
|
4
7
|
var semicolon = ";".charCodeAt(0);
|
|
5
8
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -1069,8 +1072,144 @@ class MagicString {
|
|
|
1069
1072
|
return this._replaceRegexp(searchValue, replacement);
|
|
1070
1073
|
}
|
|
1071
1074
|
}
|
|
1072
|
-
function bloxPlugin() {
|
|
1073
|
-
|
|
1075
|
+
function bloxPlugin(options = {}) {
|
|
1076
|
+
const enableSSR = options.ssr ?? false;
|
|
1077
|
+
const plugins = [];
|
|
1078
|
+
if (enableSSR) {
|
|
1079
|
+
plugins.push({
|
|
1080
|
+
name: "vite-plugin-blox-ssr",
|
|
1081
|
+
enforce: "pre",
|
|
1082
|
+
config(_config, { command }) {
|
|
1083
|
+
const cwd = process.cwd();
|
|
1084
|
+
function resolveVuePaths() {
|
|
1085
|
+
const bases = [path.join(cwd, "..", "package.json"), path.join(cwd, "package.json")];
|
|
1086
|
+
for (const base of bases) {
|
|
1087
|
+
try {
|
|
1088
|
+
const req = node_module.createRequire(base);
|
|
1089
|
+
const vueEntry = req.resolve("vue");
|
|
1090
|
+
const vuePkgJson = req.resolve("vue/package.json");
|
|
1091
|
+
const vueDir = path.dirname(vuePkgJson);
|
|
1092
|
+
return [
|
|
1093
|
+
{ find: "vue/server-renderer", replacement: path.join(vueDir, "server-renderer", "index.mjs") },
|
|
1094
|
+
{ find: "@vue/server-renderer", replacement: req.resolve("@vue/server-renderer") },
|
|
1095
|
+
{ find: "vue", replacement: vueEntry }
|
|
1096
|
+
];
|
|
1097
|
+
} catch {
|
|
1098
|
+
continue;
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
return [];
|
|
1102
|
+
}
|
|
1103
|
+
const dedupe = [
|
|
1104
|
+
"vue",
|
|
1105
|
+
"vue-router",
|
|
1106
|
+
"@vue/runtime-core",
|
|
1107
|
+
"@vue/runtime-dom",
|
|
1108
|
+
"@vue/reactivity",
|
|
1109
|
+
"pinia"
|
|
1110
|
+
];
|
|
1111
|
+
const alias = resolveVuePaths();
|
|
1112
|
+
const ssrConfig = {
|
|
1113
|
+
resolve: {
|
|
1114
|
+
dedupe,
|
|
1115
|
+
alias
|
|
1116
|
+
}
|
|
1117
|
+
};
|
|
1118
|
+
return ssrConfig;
|
|
1119
|
+
}
|
|
1120
|
+
});
|
|
1121
|
+
plugins.push({
|
|
1122
|
+
name: "vite-plugin-blox-ssr-build",
|
|
1123
|
+
enforce: "pre",
|
|
1124
|
+
config(config) {
|
|
1125
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1126
|
+
if ((_a = config.build) == null ? void 0 : _a.ssr) {
|
|
1127
|
+
return {
|
|
1128
|
+
build: {
|
|
1129
|
+
rollupOptions: {
|
|
1130
|
+
input: ((_c = (_b = config.build) == null ? void 0 : _b.rollupOptions) == null ? void 0 : _c.input) ?? "src/main.server.ts",
|
|
1131
|
+
output: ((_e = (_d = config.build) == null ? void 0 : _d.rollupOptions) == null ? void 0 : _e.output) ?? {
|
|
1132
|
+
dir: "dist/server",
|
|
1133
|
+
format: "esm"
|
|
1134
|
+
},
|
|
1135
|
+
external: [
|
|
1136
|
+
"vue",
|
|
1137
|
+
"vue-router",
|
|
1138
|
+
"vue/server-renderer",
|
|
1139
|
+
"@vue/server-renderer",
|
|
1140
|
+
...Array.isArray((_g = (_f = config.build) == null ? void 0 : _f.rollupOptions) == null ? void 0 : _g.external) ? config.build.rollupOptions.external : []
|
|
1141
|
+
]
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
return {};
|
|
1147
|
+
}
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
if (options.autoCollections ?? false) {
|
|
1151
|
+
const discoveredCollections = /* @__PURE__ */ new Map();
|
|
1152
|
+
const VIRTUAL_ID = "virtual:blox-collections";
|
|
1153
|
+
const RESOLVED_VIRTUAL_ID = `\0${VIRTUAL_ID}`;
|
|
1154
|
+
plugins.push({
|
|
1155
|
+
name: "vite-plugin-blox-collections",
|
|
1156
|
+
enforce: "pre",
|
|
1157
|
+
resolveId(id) {
|
|
1158
|
+
if (id === VIRTUAL_ID) return RESOLVED_VIRTUAL_ID;
|
|
1159
|
+
},
|
|
1160
|
+
load(id) {
|
|
1161
|
+
if (id === RESOLVED_VIRTUAL_ID) {
|
|
1162
|
+
const entries = [...discoveredCollections.values()];
|
|
1163
|
+
return `export default ${JSON.stringify(entries)}`;
|
|
1164
|
+
}
|
|
1165
|
+
},
|
|
1166
|
+
transform(code, id) {
|
|
1167
|
+
if (!id.endsWith(".vue")) return;
|
|
1168
|
+
const namePatterns = [
|
|
1169
|
+
/collectionName\s*:\s*['"]([^'"]+)['"]/g,
|
|
1170
|
+
/collection_name\s*:\s*['"]([^'"]+)['"]/g,
|
|
1171
|
+
/collection\s*:\s*['"]([^'"]+)['"]/g
|
|
1172
|
+
];
|
|
1173
|
+
const storeRe = /store\s*:\s*['"]([^'"]+)['"]/g;
|
|
1174
|
+
const stores = [];
|
|
1175
|
+
let storeMatch;
|
|
1176
|
+
while ((storeMatch = storeRe.exec(code)) !== null) {
|
|
1177
|
+
stores.push(storeMatch[1]);
|
|
1178
|
+
}
|
|
1179
|
+
const listItemsRe = /listItems\s*\(\s*['"]([^'"]+)['"]/g;
|
|
1180
|
+
let listMatch;
|
|
1181
|
+
while ((listMatch = listItemsRe.exec(code)) !== null) {
|
|
1182
|
+
const collectionName = listMatch[1];
|
|
1183
|
+
const key = `*/${collectionName}`;
|
|
1184
|
+
if (!discoveredCollections.has(key)) {
|
|
1185
|
+
discoveredCollections.set(key, { store: "*", collection: collectionName });
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
for (const pattern of namePatterns) {
|
|
1189
|
+
let match;
|
|
1190
|
+
while ((match = pattern.exec(code)) !== null) {
|
|
1191
|
+
const collection = match[1];
|
|
1192
|
+
if (["name", "label", "icon", "description", "type"].includes(collection)) continue;
|
|
1193
|
+
const store = stores[0] ?? "*";
|
|
1194
|
+
const key = `${store}/${collection}`;
|
|
1195
|
+
if (!discoveredCollections.has(key)) {
|
|
1196
|
+
discoveredCollections.set(key, { store, collection });
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
},
|
|
1201
|
+
generateBundle() {
|
|
1202
|
+
if (discoveredCollections.size === 0) return;
|
|
1203
|
+
const entries = [...discoveredCollections.values()];
|
|
1204
|
+
this.emitFile({
|
|
1205
|
+
type: "asset",
|
|
1206
|
+
fileName: ".blox-collections.json",
|
|
1207
|
+
source: JSON.stringify(entries, null, 2)
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
plugins.push({
|
|
1074
1213
|
name: "vite-plugin-blox",
|
|
1075
1214
|
enforce: "pre",
|
|
1076
1215
|
transform(code, id) {
|
|
@@ -1163,6 +1302,7 @@ ${openTag}${remaining}${closeTag}`;
|
|
|
1163
1302
|
map: s.generateMap({ hires: true })
|
|
1164
1303
|
};
|
|
1165
1304
|
}
|
|
1166
|
-
};
|
|
1305
|
+
});
|
|
1306
|
+
return plugins;
|
|
1167
1307
|
}
|
|
1168
1308
|
exports.bloxPlugin = bloxPlugin;
|
package/dist/vite-plugin.d.ts
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
|
+
export interface BloxPluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Enable SSR-aware config injection.
|
|
5
|
+
* When true, adds `resolve.dedupe`, `resolve.alias` for Vue,
|
|
6
|
+
* and SSR build rollup options automatically.
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
ssr?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Enable collection auto-discovery from block source files.
|
|
12
|
+
* When true, scans `.vue` files for datastore collection references
|
|
13
|
+
* and emits a `virtual:blox-collections` module and a
|
|
14
|
+
* `.blox-collections.json` manifest in the output directory.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
autoCollections?: boolean;
|
|
18
|
+
}
|
|
2
19
|
/**
|
|
3
|
-
* Vite plugin that
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```vue
|
|
9
|
-
* <script setup lang="ts">
|
|
10
|
-
* import { defineBlock } from '@bagelink/blox'
|
|
11
|
-
* import { defineSchema, $ } from '@bagelink/vue'
|
|
12
|
-
*
|
|
13
|
-
* // Either inline:
|
|
14
|
-
* defineBlock({ name: 'hero', label: 'Hero', schema: defineSchema({ ... }) })
|
|
15
|
-
*
|
|
16
|
-
* // Or via variable (also hoisted automatically):
|
|
17
|
-
* const schema = defineSchema({ ... })
|
|
18
|
-
* defineBlock({ name: 'hero', label: 'Hero', schema })
|
|
19
|
-
*
|
|
20
|
-
* defineProps<HeroProps>()
|
|
21
|
-
* </script>
|
|
22
|
-
* ```
|
|
20
|
+
* Vite plugin that:
|
|
21
|
+
* 1. Hoists `defineBlock(...)` out of `<script setup>` into a plain `<script>` block.
|
|
22
|
+
* 2. (When `ssr: true`) Injects Vue dedupe, alias, and SSR rollup config
|
|
23
|
+
* so consumer `vite.config.ts` doesn't need any of that boilerplate.
|
|
23
24
|
*/
|
|
24
|
-
export declare function bloxPlugin(): Plugin;
|
|
25
|
+
export declare function bloxPlugin(options?: BloxPluginOptions): Plugin[];
|
|
25
26
|
//# sourceMappingURL=vite-plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,MAAM,CAAA;AAM9C,MAAM,WAAW,iBAAiB;IACjC;;;;;OAKG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,EAAE,CAgTpE"}
|
package/dist/vite-plugin.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { join, dirname } from "node:path";
|
|
3
|
+
import process from "node:process";
|
|
1
4
|
var comma = ",".charCodeAt(0);
|
|
2
5
|
var semicolon = ";".charCodeAt(0);
|
|
3
6
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -1067,8 +1070,144 @@ class MagicString {
|
|
|
1067
1070
|
return this._replaceRegexp(searchValue, replacement);
|
|
1068
1071
|
}
|
|
1069
1072
|
}
|
|
1070
|
-
function bloxPlugin() {
|
|
1071
|
-
|
|
1073
|
+
function bloxPlugin(options = {}) {
|
|
1074
|
+
const enableSSR = options.ssr ?? false;
|
|
1075
|
+
const plugins = [];
|
|
1076
|
+
if (enableSSR) {
|
|
1077
|
+
plugins.push({
|
|
1078
|
+
name: "vite-plugin-blox-ssr",
|
|
1079
|
+
enforce: "pre",
|
|
1080
|
+
config(_config, { command }) {
|
|
1081
|
+
const cwd = process.cwd();
|
|
1082
|
+
function resolveVuePaths() {
|
|
1083
|
+
const bases = [join(cwd, "..", "package.json"), join(cwd, "package.json")];
|
|
1084
|
+
for (const base of bases) {
|
|
1085
|
+
try {
|
|
1086
|
+
const req = createRequire(base);
|
|
1087
|
+
const vueEntry = req.resolve("vue");
|
|
1088
|
+
const vuePkgJson = req.resolve("vue/package.json");
|
|
1089
|
+
const vueDir = dirname(vuePkgJson);
|
|
1090
|
+
return [
|
|
1091
|
+
{ find: "vue/server-renderer", replacement: join(vueDir, "server-renderer", "index.mjs") },
|
|
1092
|
+
{ find: "@vue/server-renderer", replacement: req.resolve("@vue/server-renderer") },
|
|
1093
|
+
{ find: "vue", replacement: vueEntry }
|
|
1094
|
+
];
|
|
1095
|
+
} catch {
|
|
1096
|
+
continue;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
return [];
|
|
1100
|
+
}
|
|
1101
|
+
const dedupe = [
|
|
1102
|
+
"vue",
|
|
1103
|
+
"vue-router",
|
|
1104
|
+
"@vue/runtime-core",
|
|
1105
|
+
"@vue/runtime-dom",
|
|
1106
|
+
"@vue/reactivity",
|
|
1107
|
+
"pinia"
|
|
1108
|
+
];
|
|
1109
|
+
const alias = resolveVuePaths();
|
|
1110
|
+
const ssrConfig = {
|
|
1111
|
+
resolve: {
|
|
1112
|
+
dedupe,
|
|
1113
|
+
alias
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1116
|
+
return ssrConfig;
|
|
1117
|
+
}
|
|
1118
|
+
});
|
|
1119
|
+
plugins.push({
|
|
1120
|
+
name: "vite-plugin-blox-ssr-build",
|
|
1121
|
+
enforce: "pre",
|
|
1122
|
+
config(config) {
|
|
1123
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1124
|
+
if ((_a = config.build) == null ? void 0 : _a.ssr) {
|
|
1125
|
+
return {
|
|
1126
|
+
build: {
|
|
1127
|
+
rollupOptions: {
|
|
1128
|
+
input: ((_c = (_b = config.build) == null ? void 0 : _b.rollupOptions) == null ? void 0 : _c.input) ?? "src/main.server.ts",
|
|
1129
|
+
output: ((_e = (_d = config.build) == null ? void 0 : _d.rollupOptions) == null ? void 0 : _e.output) ?? {
|
|
1130
|
+
dir: "dist/server",
|
|
1131
|
+
format: "esm"
|
|
1132
|
+
},
|
|
1133
|
+
external: [
|
|
1134
|
+
"vue",
|
|
1135
|
+
"vue-router",
|
|
1136
|
+
"vue/server-renderer",
|
|
1137
|
+
"@vue/server-renderer",
|
|
1138
|
+
...Array.isArray((_g = (_f = config.build) == null ? void 0 : _f.rollupOptions) == null ? void 0 : _g.external) ? config.build.rollupOptions.external : []
|
|
1139
|
+
]
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
};
|
|
1143
|
+
}
|
|
1144
|
+
return {};
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
if (options.autoCollections ?? false) {
|
|
1149
|
+
const discoveredCollections = /* @__PURE__ */ new Map();
|
|
1150
|
+
const VIRTUAL_ID = "virtual:blox-collections";
|
|
1151
|
+
const RESOLVED_VIRTUAL_ID = `\0${VIRTUAL_ID}`;
|
|
1152
|
+
plugins.push({
|
|
1153
|
+
name: "vite-plugin-blox-collections",
|
|
1154
|
+
enforce: "pre",
|
|
1155
|
+
resolveId(id) {
|
|
1156
|
+
if (id === VIRTUAL_ID) return RESOLVED_VIRTUAL_ID;
|
|
1157
|
+
},
|
|
1158
|
+
load(id) {
|
|
1159
|
+
if (id === RESOLVED_VIRTUAL_ID) {
|
|
1160
|
+
const entries = [...discoveredCollections.values()];
|
|
1161
|
+
return `export default ${JSON.stringify(entries)}`;
|
|
1162
|
+
}
|
|
1163
|
+
},
|
|
1164
|
+
transform(code, id) {
|
|
1165
|
+
if (!id.endsWith(".vue")) return;
|
|
1166
|
+
const namePatterns = [
|
|
1167
|
+
/collectionName\s*:\s*['"]([^'"]+)['"]/g,
|
|
1168
|
+
/collection_name\s*:\s*['"]([^'"]+)['"]/g,
|
|
1169
|
+
/collection\s*:\s*['"]([^'"]+)['"]/g
|
|
1170
|
+
];
|
|
1171
|
+
const storeRe = /store\s*:\s*['"]([^'"]+)['"]/g;
|
|
1172
|
+
const stores = [];
|
|
1173
|
+
let storeMatch;
|
|
1174
|
+
while ((storeMatch = storeRe.exec(code)) !== null) {
|
|
1175
|
+
stores.push(storeMatch[1]);
|
|
1176
|
+
}
|
|
1177
|
+
const listItemsRe = /listItems\s*\(\s*['"]([^'"]+)['"]/g;
|
|
1178
|
+
let listMatch;
|
|
1179
|
+
while ((listMatch = listItemsRe.exec(code)) !== null) {
|
|
1180
|
+
const collectionName = listMatch[1];
|
|
1181
|
+
const key = `*/${collectionName}`;
|
|
1182
|
+
if (!discoveredCollections.has(key)) {
|
|
1183
|
+
discoveredCollections.set(key, { store: "*", collection: collectionName });
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
for (const pattern of namePatterns) {
|
|
1187
|
+
let match;
|
|
1188
|
+
while ((match = pattern.exec(code)) !== null) {
|
|
1189
|
+
const collection = match[1];
|
|
1190
|
+
if (["name", "label", "icon", "description", "type"].includes(collection)) continue;
|
|
1191
|
+
const store = stores[0] ?? "*";
|
|
1192
|
+
const key = `${store}/${collection}`;
|
|
1193
|
+
if (!discoveredCollections.has(key)) {
|
|
1194
|
+
discoveredCollections.set(key, { store, collection });
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
},
|
|
1199
|
+
generateBundle() {
|
|
1200
|
+
if (discoveredCollections.size === 0) return;
|
|
1201
|
+
const entries = [...discoveredCollections.values()];
|
|
1202
|
+
this.emitFile({
|
|
1203
|
+
type: "asset",
|
|
1204
|
+
fileName: ".blox-collections.json",
|
|
1205
|
+
source: JSON.stringify(entries, null, 2)
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
plugins.push({
|
|
1072
1211
|
name: "vite-plugin-blox",
|
|
1073
1212
|
enforce: "pre",
|
|
1074
1213
|
transform(code, id) {
|
|
@@ -1161,7 +1300,8 @@ ${openTag}${remaining}${closeTag}`;
|
|
|
1161
1300
|
map: s.generateMap({ hires: true })
|
|
1162
1301
|
};
|
|
1163
1302
|
}
|
|
1164
|
-
};
|
|
1303
|
+
});
|
|
1304
|
+
return plugins;
|
|
1165
1305
|
}
|
|
1166
1306
|
export {
|
|
1167
1307
|
bloxPlugin
|