@void/vue 0.7.12 → 0.7.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/plugin.d.mts +1 -1
- package/dist/plugin.mjs +26 -15
- package/package.json +3 -3
package/dist/plugin.d.mts
CHANGED
|
@@ -6,6 +6,6 @@ type VoidVueOptions = Readonly<{
|
|
|
6
6
|
vue?: Parameters<typeof vue>[0];
|
|
7
7
|
viewTransitions?: boolean;
|
|
8
8
|
}>;
|
|
9
|
-
declare function voidVue(options?: VoidVueOptions):
|
|
9
|
+
declare function voidVue(options?: VoidVueOptions): Array<Plugin>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { VoidVueOptions, voidVue };
|
package/dist/plugin.mjs
CHANGED
|
@@ -142,6 +142,23 @@ const COMPONENT_EXTENSIONS = [
|
|
|
142
142
|
".ts",
|
|
143
143
|
".js"
|
|
144
144
|
];
|
|
145
|
+
const ISLAND_IMPORT_RE = /import\s+([$_A-Za-z][$_\w]*)\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*,?\s*\}/g;
|
|
146
|
+
function findIslandImports(code) {
|
|
147
|
+
const imports = [];
|
|
148
|
+
let match;
|
|
149
|
+
ISLAND_IMPORT_RE.lastIndex = 0;
|
|
150
|
+
while ((match = ISLAND_IMPORT_RE.exec(code)) !== null) {
|
|
151
|
+
const specifierRaw = match[2];
|
|
152
|
+
imports.push({
|
|
153
|
+
statement: match[0],
|
|
154
|
+
importName: match[1],
|
|
155
|
+
specifierRaw,
|
|
156
|
+
specifier: specifierRaw.slice(1, -1),
|
|
157
|
+
hydrate: match[3].slice(1, -1)
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return imports;
|
|
161
|
+
}
|
|
145
162
|
function extractCss(filePath) {
|
|
146
163
|
const code = readFileSync(filePath, "utf-8");
|
|
147
164
|
const parts = [];
|
|
@@ -185,7 +202,6 @@ function islandsPlugin(pagesDir) {
|
|
|
185
202
|
async buildStart() {
|
|
186
203
|
if (existsSync(pagesDir)) {
|
|
187
204
|
pageScan = await scanPages(root);
|
|
188
|
-
const importAttrRe = /import\s+\w+\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*\}/g;
|
|
189
205
|
const filesToScan = [
|
|
190
206
|
...pageScan.pages.map((page) => ({
|
|
191
207
|
filePath: page.componentPath,
|
|
@@ -205,11 +221,9 @@ function islandsPlugin(pagesDir) {
|
|
|
205
221
|
const filePath = resolve(pagesDir, entry.filePath);
|
|
206
222
|
const code = readFileSync(filePath, "utf-8");
|
|
207
223
|
const importerDir = dirname(filePath);
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const spec = importMatch[1].slice(1, -1);
|
|
212
|
-
const strategy = importMatch[2].slice(1, -1);
|
|
224
|
+
for (const islandImport of findIslandImports(code)) {
|
|
225
|
+
const spec = islandImport.specifier;
|
|
226
|
+
const strategy = islandImport.hydrate;
|
|
213
227
|
const absPath = resolveSpecifier(spec, importerDir, COMPONENT_EXTENSIONS);
|
|
214
228
|
if (absPath) {
|
|
215
229
|
const islandId = normalizePath(relative(root, absPath)).replace(/\.[^.]+$/, "");
|
|
@@ -267,18 +281,15 @@ function islandsPlugin(pagesDir) {
|
|
|
267
281
|
filter: { id: /\.island\.vue$/ },
|
|
268
282
|
handler(code, id) {
|
|
269
283
|
if (/import\s+\{[^}]*\buseForm\b/.test(code)) this.warn(`islands: useForm cannot be imported in island page '${id}'. Use useIslandForm instead.`);
|
|
270
|
-
const importAttrRe = /import\s+(\w+)\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*\}/g;
|
|
271
284
|
const importerDir = dirname(id);
|
|
272
285
|
let transformed = code;
|
|
273
286
|
const wrappers = [];
|
|
274
287
|
let idx = 0;
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
const
|
|
279
|
-
const
|
|
280
|
-
const spec = specRaw.slice(1, -1);
|
|
281
|
-
const strategy = strategyRaw.slice(1, -1);
|
|
288
|
+
for (const islandImport of findIslandImports(code)) {
|
|
289
|
+
const name = islandImport.importName;
|
|
290
|
+
const specRaw = islandImport.specifierRaw;
|
|
291
|
+
const strategy = islandImport.hydrate;
|
|
292
|
+
const spec = islandImport.specifier;
|
|
282
293
|
const rawName = `_raw_island_${idx++}`;
|
|
283
294
|
const absPath = resolveSpecifier(spec, importerDir, COMPONENT_EXTENSIONS);
|
|
284
295
|
if (absPath) {
|
|
@@ -291,7 +302,7 @@ function islandsPlugin(pagesDir) {
|
|
|
291
302
|
}
|
|
292
303
|
const islandId = absPath ? normalizePath(relative(root, absPath)).replace(/\.[^.]+$/, "") : spec;
|
|
293
304
|
const replacement = `import ${rawName} from ${specRaw}`;
|
|
294
|
-
transformed = transformed.replace(
|
|
305
|
+
transformed = transformed.replace(islandImport.statement, replacement);
|
|
295
306
|
wrappers.push(`const ${name} = { inheritAttrs: false, render() { const props = this.$attrs; return _h_island("div", { "data-island": ${JSON.stringify(islandId)}, "data-props": JSON.stringify(props), "data-hydrate": ${JSON.stringify(strategy)} }, _h_island(${rawName}, props)); } };`);
|
|
296
307
|
}
|
|
297
308
|
if (wrappers.length > 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@void/vue",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.13",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/voidzero-dev/void.git",
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.20",
|
|
45
45
|
"vite-plus": "^0.1.20",
|
|
46
46
|
"vue": "^3.5.34",
|
|
47
|
-
"void": "0.7.
|
|
47
|
+
"void": "0.7.13"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"vite": "^8.0.0",
|
|
51
51
|
"vue": "^3.5.0",
|
|
52
|
-
"void": "0.7.
|
|
52
|
+
"void": "0.7.13"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "vp pack",
|