coffeehaml 0.7.1 → 0.7.3

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.
@@ -1,78 +0,0 @@
1
- // Generated by CoffeeScript 2.7.0
2
- // vite-plugin.coffee — Vite plugin for CoffeeHaml
3
- var COFFEEHAML_RE, coffeehaml, componentNameFromPath;
4
-
5
- import {
6
- compile
7
- } from './compiler.js';
8
-
9
- import {
10
- basename
11
- } from 'path';
12
-
13
- COFFEEHAML_RE = /\.(coffeehaml|cohaml|chaml)$/;
14
-
15
- componentNameFromPath = function(filepath) {
16
- var stem;
17
- stem = basename(filepath).split('.').shift() || 'Component';
18
- return stem.charAt(0).toUpperCase() + stem.slice(1);
19
- };
20
-
21
- export default coffeehaml = function(options = {}) {
22
- var compilerOpts, ref;
23
- compilerOpts = Object.assign({
24
- sourceMap: true,
25
- wrap: 'component'
26
- }, (ref = options.compilerOptions) != null ? ref : {});
27
- return {
28
- name: 'coffeehaml',
29
- transform: function(code, id) {
30
- var err, finalCode, name, postamble, preamble, result;
31
- if (!COFFEEHAML_RE.test(id)) {
32
- return;
33
- }
34
- result = compile(code, ...compilerOpts, {
35
- filename: id,
36
- componentName: compilerOpts.componentName || componentNameFromPath(id)
37
- });
38
- preamble = '';
39
- postamble = '';
40
- if (compilerOpts.wrap && compilerOpts.wrap !== 'none' && !Array.isArray(compilerOpts.wrap)) {
41
- preamble = '// @refresh reset\n';
42
- name = compilerOpts.componentName || componentNameFromPath(id);
43
- postamble = `\nif (import.meta.hot) {
44
- import.meta.hot.accept((mod) => {
45
- if (mod?.${name}) import.meta.hot?.data?.refresh?.();
46
- });
47
- }\n`;
48
- }
49
- finalCode = preamble + result.code + postamble;
50
- if (result.errors.length > 0) {
51
- err = result.errors[0];
52
- this.error({
53
- message: err.message
54
- }, id, {
55
- loc: err.location ? {
56
- line: err.location.start.line + 1,
57
- column: err.location.start.column + 1
58
- } : void 0
59
- });
60
- return null;
61
- }
62
- return {
63
- code: finalCode,
64
- map: result.sourceMap ? {
65
- mappings: result.sourceMap
66
- } : null
67
- };
68
- },
69
- handleHotUpdate: function({file, server}) {
70
- if (COFFEEHAML_RE.test(file)) {
71
- server.ws.send({
72
- type: 'full-reload'
73
- });
74
- return [];
75
- }
76
- }
77
- };
78
- };