@danielx/civet 0.8.7 → 0.8.9
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/CHANGELOG.md +27 -7
- package/dist/browser.js +1169 -734
- package/dist/main.js +1169 -734
- package/dist/main.mjs +1169 -734
- package/dist/types.d.ts +1 -0
- package/dist/unplugin/unplugin.js +47 -22
- package/dist/unplugin/unplugin.mjs +47 -22
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -105,6 +105,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
105
105
|
const transformTS = options.emitDeclaration || options.typecheck;
|
|
106
106
|
const outExt = options.outputExtension ?? (options.ts === "preserve" ? ".tsx" : ".jsx");
|
|
107
107
|
const implicitExtension = options.implicitExtension ?? true;
|
|
108
|
+
let aliasResolver;
|
|
108
109
|
let fsMap = /* @__PURE__ */ new Map();
|
|
109
110
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
110
111
|
let compilerOptions, compilerOptionsWithSourceMap;
|
|
@@ -121,7 +122,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
121
122
|
};
|
|
122
123
|
};
|
|
123
124
|
const cache = options.cache ? /* @__PURE__ */ new Map() : void 0;
|
|
124
|
-
|
|
125
|
+
const plugin = {
|
|
125
126
|
name: "unplugin-civet",
|
|
126
127
|
enforce: "pre",
|
|
127
128
|
async buildStart() {
|
|
@@ -375,8 +376,14 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
375
376
|
}
|
|
376
377
|
},
|
|
377
378
|
resolveId(id, importer, options2) {
|
|
379
|
+
if (aliasResolver != null) {
|
|
380
|
+
id = aliasResolver(id);
|
|
381
|
+
}
|
|
378
382
|
if (/\0/.test(id))
|
|
379
383
|
return null;
|
|
384
|
+
if (plugin.__virtualModulePrefix && importer?.startsWith(plugin.__virtualModulePrefix)) {
|
|
385
|
+
importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
|
|
386
|
+
}
|
|
380
387
|
let postfix;
|
|
381
388
|
({ id, postfix } = cleanCivetId(id));
|
|
382
389
|
let ref1;
|
|
@@ -519,35 +526,28 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
519
526
|
config.resolve.extensions ??= DEFAULT_EXTENSIONS;
|
|
520
527
|
config.resolve.extensions.push(".civet");
|
|
521
528
|
}
|
|
522
|
-
;
|
|
523
|
-
return;
|
|
524
529
|
},
|
|
525
530
|
async transformIndexHtml(html) {
|
|
526
|
-
return html.replace(
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
return name.toLowerCase() === "src" && value ? attr.replace(
|
|
536
|
-
/(\.civet)(['"]?)$/,
|
|
537
|
-
(_, extension, endQuote) => {
|
|
538
|
-
return `${extension}${outExt}?transform${endQuote}`;
|
|
539
|
-
}
|
|
540
|
-
) : attr;
|
|
531
|
+
return html.replace(/<!--[^]*?-->|<[^<>]*>/g, (tag) => {
|
|
532
|
+
return tag.replace(/<\s*script\b[^<>]*>/gi, (script) => {
|
|
533
|
+
return script.replace(
|
|
534
|
+
/([:_\p{ID_Start}][:\p{ID_Continue}]*)(\s*=\s*("[^"]*"|'[^']*'|[^\s"'=<>`]*))?/gu,
|
|
535
|
+
(attr, name, value) => {
|
|
536
|
+
return name.toLowerCase() === "src" && value ? attr.replace(
|
|
537
|
+
/(\.civet)(['"]?)$/,
|
|
538
|
+
(_, extension, endQuote) => {
|
|
539
|
+
return `${extension}${outExt}?transform${endQuote}`;
|
|
541
540
|
}
|
|
542
|
-
);
|
|
541
|
+
) : attr;
|
|
543
542
|
}
|
|
544
543
|
);
|
|
545
|
-
}
|
|
546
|
-
);
|
|
544
|
+
});
|
|
545
|
+
});
|
|
547
546
|
},
|
|
548
547
|
handleHotUpdate({ file, server, modules }) {
|
|
549
|
-
if (!file.endsWith(".civet"))
|
|
548
|
+
if (!file.endsWith(".civet")) {
|
|
550
549
|
return;
|
|
550
|
+
}
|
|
551
551
|
const resolvedId = slash(import_path.default.resolve(file) + outExt);
|
|
552
552
|
const module2 = server.moduleGraph.getModuleById(resolvedId);
|
|
553
553
|
if (module2) {
|
|
@@ -556,8 +556,33 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
556
556
|
}
|
|
557
557
|
return modules;
|
|
558
558
|
}
|
|
559
|
+
},
|
|
560
|
+
webpack(compiler) {
|
|
561
|
+
if (implicitExtension) {
|
|
562
|
+
compiler.options.resolve.extensions.unshift(".civet");
|
|
563
|
+
}
|
|
564
|
+
return aliasResolver = (id) => {
|
|
565
|
+
let ref2;
|
|
566
|
+
for (const key in ref2 = compiler.options.resolve.alias) {
|
|
567
|
+
const value = ref2[key];
|
|
568
|
+
if (key.endsWith("$")) {
|
|
569
|
+
if (id === key.slice(0, -1)) {
|
|
570
|
+
return typeof value === "string" ? value : "\0";
|
|
571
|
+
}
|
|
572
|
+
} else {
|
|
573
|
+
if (id === key || id.startsWith(key + "/")) {
|
|
574
|
+
if (!(typeof value === "string")) {
|
|
575
|
+
return "\0";
|
|
576
|
+
}
|
|
577
|
+
return value + id.slice(key.length);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
return id;
|
|
582
|
+
};
|
|
559
583
|
}
|
|
560
584
|
};
|
|
585
|
+
return plugin;
|
|
561
586
|
};
|
|
562
587
|
var unplugin = (0, import_unplugin.createUnplugin)(rawPlugin);
|
|
563
588
|
var unplugin_civet_default = unplugin;
|
|
@@ -73,6 +73,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
73
73
|
const transformTS = options.emitDeclaration || options.typecheck;
|
|
74
74
|
const outExt = options.outputExtension ?? (options.ts === "preserve" ? ".tsx" : ".jsx");
|
|
75
75
|
const implicitExtension = options.implicitExtension ?? true;
|
|
76
|
+
let aliasResolver;
|
|
76
77
|
let fsMap = /* @__PURE__ */ new Map();
|
|
77
78
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
78
79
|
let compilerOptions, compilerOptionsWithSourceMap;
|
|
@@ -89,7 +90,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
89
90
|
};
|
|
90
91
|
};
|
|
91
92
|
const cache = options.cache ? /* @__PURE__ */ new Map() : void 0;
|
|
92
|
-
|
|
93
|
+
const plugin = {
|
|
93
94
|
name: "unplugin-civet",
|
|
94
95
|
enforce: "pre",
|
|
95
96
|
async buildStart() {
|
|
@@ -343,8 +344,14 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
343
344
|
}
|
|
344
345
|
},
|
|
345
346
|
resolveId(id, importer, options2) {
|
|
347
|
+
if (aliasResolver != null) {
|
|
348
|
+
id = aliasResolver(id);
|
|
349
|
+
}
|
|
346
350
|
if (/\0/.test(id))
|
|
347
351
|
return null;
|
|
352
|
+
if (plugin.__virtualModulePrefix && importer?.startsWith(plugin.__virtualModulePrefix)) {
|
|
353
|
+
importer = decodeURIComponent(importer.slice(plugin.__virtualModulePrefix.length));
|
|
354
|
+
}
|
|
348
355
|
let postfix;
|
|
349
356
|
({ id, postfix } = cleanCivetId(id));
|
|
350
357
|
let ref1;
|
|
@@ -487,35 +494,28 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
487
494
|
config.resolve.extensions ??= DEFAULT_EXTENSIONS;
|
|
488
495
|
config.resolve.extensions.push(".civet");
|
|
489
496
|
}
|
|
490
|
-
;
|
|
491
|
-
return;
|
|
492
497
|
},
|
|
493
498
|
async transformIndexHtml(html) {
|
|
494
|
-
return html.replace(
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
return name.toLowerCase() === "src" && value ? attr.replace(
|
|
504
|
-
/(\.civet)(['"]?)$/,
|
|
505
|
-
(_, extension, endQuote) => {
|
|
506
|
-
return `${extension}${outExt}?transform${endQuote}`;
|
|
507
|
-
}
|
|
508
|
-
) : attr;
|
|
499
|
+
return html.replace(/<!--[^]*?-->|<[^<>]*>/g, (tag) => {
|
|
500
|
+
return tag.replace(/<\s*script\b[^<>]*>/gi, (script) => {
|
|
501
|
+
return script.replace(
|
|
502
|
+
/([:_\p{ID_Start}][:\p{ID_Continue}]*)(\s*=\s*("[^"]*"|'[^']*'|[^\s"'=<>`]*))?/gu,
|
|
503
|
+
(attr, name, value) => {
|
|
504
|
+
return name.toLowerCase() === "src" && value ? attr.replace(
|
|
505
|
+
/(\.civet)(['"]?)$/,
|
|
506
|
+
(_, extension, endQuote) => {
|
|
507
|
+
return `${extension}${outExt}?transform${endQuote}`;
|
|
509
508
|
}
|
|
510
|
-
);
|
|
509
|
+
) : attr;
|
|
511
510
|
}
|
|
512
511
|
);
|
|
513
|
-
}
|
|
514
|
-
);
|
|
512
|
+
});
|
|
513
|
+
});
|
|
515
514
|
},
|
|
516
515
|
handleHotUpdate({ file, server, modules }) {
|
|
517
|
-
if (!file.endsWith(".civet"))
|
|
516
|
+
if (!file.endsWith(".civet")) {
|
|
518
517
|
return;
|
|
518
|
+
}
|
|
519
519
|
const resolvedId = slash(path.resolve(file) + outExt);
|
|
520
520
|
const module = server.moduleGraph.getModuleById(resolvedId);
|
|
521
521
|
if (module) {
|
|
@@ -524,8 +524,33 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
524
524
|
}
|
|
525
525
|
return modules;
|
|
526
526
|
}
|
|
527
|
+
},
|
|
528
|
+
webpack(compiler) {
|
|
529
|
+
if (implicitExtension) {
|
|
530
|
+
compiler.options.resolve.extensions.unshift(".civet");
|
|
531
|
+
}
|
|
532
|
+
return aliasResolver = (id) => {
|
|
533
|
+
let ref2;
|
|
534
|
+
for (const key in ref2 = compiler.options.resolve.alias) {
|
|
535
|
+
const value = ref2[key];
|
|
536
|
+
if (key.endsWith("$")) {
|
|
537
|
+
if (id === key.slice(0, -1)) {
|
|
538
|
+
return typeof value === "string" ? value : "\0";
|
|
539
|
+
}
|
|
540
|
+
} else {
|
|
541
|
+
if (id === key || id.startsWith(key + "/")) {
|
|
542
|
+
if (!(typeof value === "string")) {
|
|
543
|
+
return "\0";
|
|
544
|
+
}
|
|
545
|
+
return value + id.slice(key.length);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
return id;
|
|
550
|
+
};
|
|
527
551
|
}
|
|
528
552
|
};
|
|
553
|
+
return plugin;
|
|
529
554
|
};
|
|
530
555
|
var unplugin = createUnplugin(rawPlugin);
|
|
531
556
|
var unplugin_civet_default = unplugin;
|