@danielx/civet 0.11.2 → 0.11.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,3 +1,10 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
1
8
  // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
2
9
  import { createUnplugin } from "unplugin";
3
10
  import civet, { decode, lib, SourceMap } from "@danielx/civet";
@@ -8,7 +15,180 @@ import {
8
15
  } from "@danielx/civet/ts-diagnostic";
9
16
  import * as fs from "fs";
10
17
  import path from "path";
11
- import * as tsvfs from "@typescript/vfs";
18
+
19
+ // node_modules/@typescript/vfs/dist/vfs.esm.js
20
+ function _extends() {
21
+ _extends = Object.assign ? Object.assign.bind() : function(target) {
22
+ for (var i = 1; i < arguments.length; i++) {
23
+ var source = arguments[i];
24
+ for (var key in source) {
25
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
26
+ target[key] = source[key];
27
+ }
28
+ }
29
+ }
30
+ return target;
31
+ };
32
+ return _extends.apply(this, arguments);
33
+ }
34
+ var hasLocalStorage = false;
35
+ try {
36
+ hasLocalStorage = typeof localStorage !== "undefined";
37
+ } catch (error) {
38
+ }
39
+ var hasProcess = typeof process !== "undefined";
40
+ var shouldDebug = hasLocalStorage && /* @__PURE__ */ localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;
41
+ var debugLog = shouldDebug ? console.log : function(_message) {
42
+ return "";
43
+ };
44
+ function notImplemented(methodName) {
45
+ throw new Error("Method '" + methodName + "' is not implemented.");
46
+ }
47
+ function audit(name, fn) {
48
+ return function() {
49
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
50
+ args[_key] = arguments[_key];
51
+ }
52
+ var res = fn.apply(void 0, args);
53
+ var smallres = typeof res === "string" ? res.slice(0, 80) + "..." : res;
54
+ debugLog.apply(void 0, ["> " + name].concat(args));
55
+ debugLog("< " + smallres);
56
+ return res;
57
+ };
58
+ }
59
+ var defaultCompilerOptions = function defaultCompilerOptions2(ts) {
60
+ return _extends({}, ts.getDefaultCompilerOptions(), {
61
+ jsx: ts.JsxEmit.React,
62
+ strict: true,
63
+ esModuleInterop: true,
64
+ module: ts.ModuleKind.ESNext,
65
+ suppressOutputPathCheck: true,
66
+ skipLibCheck: true,
67
+ skipDefaultLibCheck: true,
68
+ moduleResolution: ts.ModuleResolutionKind.NodeJs
69
+ });
70
+ };
71
+ function createFSBackedSystem(files, _projectRoot, ts, tsLibDirectory) {
72
+ var root = _projectRoot + "/vfs";
73
+ var path2 = requirePath();
74
+ var nodeSys = ts.sys;
75
+ var tsLib = tsLibDirectory != null ? tsLibDirectory : path2.dirname(__require.resolve("typescript"));
76
+ return {
77
+ // @ts-ignore
78
+ name: "fs-vfs",
79
+ root,
80
+ args: [],
81
+ createDirectory: function createDirectory() {
82
+ return notImplemented("createDirectory");
83
+ },
84
+ // TODO: could make a real file tree
85
+ directoryExists: audit("directoryExists", function(directory) {
86
+ return Array.from(files.keys()).some(function(path3) {
87
+ return path3.startsWith(directory);
88
+ }) || nodeSys.directoryExists(directory);
89
+ }),
90
+ exit: nodeSys.exit,
91
+ fileExists: audit("fileExists", function(fileName) {
92
+ if (files.has(fileName)) return true;
93
+ if (fileName.includes("tsconfig.json") || fileName.includes("tsconfig.json")) return false;
94
+ if (fileName.startsWith("/lib")) {
95
+ var tsLibName = tsLib + "/" + fileName.replace("/", "");
96
+ return nodeSys.fileExists(tsLibName);
97
+ }
98
+ return nodeSys.fileExists(fileName);
99
+ }),
100
+ getCurrentDirectory: function getCurrentDirectory() {
101
+ return root;
102
+ },
103
+ getDirectories: nodeSys.getDirectories,
104
+ getExecutingFilePath: function getExecutingFilePath() {
105
+ return notImplemented("getExecutingFilePath");
106
+ },
107
+ readDirectory: audit("readDirectory", function() {
108
+ if ((arguments.length <= 0 ? void 0 : arguments[0]) === "/") {
109
+ return Array.from(files.keys());
110
+ } else {
111
+ return nodeSys.readDirectory.apply(nodeSys, arguments);
112
+ }
113
+ }),
114
+ readFile: audit("readFile", function(fileName) {
115
+ if (files.has(fileName)) return files.get(fileName);
116
+ if (fileName.startsWith("/lib")) {
117
+ var tsLibName = tsLib + "/" + fileName.replace("/", "");
118
+ var result = nodeSys.readFile(tsLibName);
119
+ if (!result) {
120
+ var libs = nodeSys.readDirectory(tsLib);
121
+ throw new Error("TSVFS: A request was made for " + tsLibName + " but there wasn't a file found in the file map. You likely have a mismatch in the compiler options for the CDN download vs the compiler program. Existing Libs: " + libs + ".");
122
+ }
123
+ return result;
124
+ }
125
+ return nodeSys.readFile(fileName);
126
+ }),
127
+ resolvePath: function resolvePath(path3) {
128
+ if (files.has(path3)) return path3;
129
+ return nodeSys.resolvePath(path3);
130
+ },
131
+ newLine: "\n",
132
+ useCaseSensitiveFileNames: true,
133
+ write: function write() {
134
+ return notImplemented("write");
135
+ },
136
+ writeFile: function writeFile(fileName, contents) {
137
+ files.set(fileName, contents);
138
+ },
139
+ deleteFile: function deleteFile(fileName) {
140
+ files["delete"](fileName);
141
+ },
142
+ realpath: nodeSys.realpath
143
+ };
144
+ }
145
+ function createVirtualCompilerHost(sys, compilerOptions, ts) {
146
+ var sourceFiles = /* @__PURE__ */ new Map();
147
+ var save = function save2(sourceFile) {
148
+ sourceFiles.set(sourceFile.fileName, sourceFile);
149
+ return sourceFile;
150
+ };
151
+ var vHost = {
152
+ compilerHost: _extends({}, sys, {
153
+ getCanonicalFileName: function getCanonicalFileName(fileName) {
154
+ return fileName;
155
+ },
156
+ getDefaultLibFileName: function getDefaultLibFileName() {
157
+ return "/" + ts.getDefaultLibFileName(compilerOptions);
158
+ },
159
+ // '/lib.d.ts',
160
+ // getDefaultLibLocation: () => '/',
161
+ getNewLine: function getNewLine() {
162
+ return sys.newLine;
163
+ },
164
+ getSourceFile: function getSourceFile(fileName, languageVersionOrOptions) {
165
+ var _ref;
166
+ return sourceFiles.get(fileName) || save(ts.createSourceFile(fileName, sys.readFile(fileName), (_ref = languageVersionOrOptions != null ? languageVersionOrOptions : compilerOptions.target) != null ? _ref : defaultCompilerOptions(ts).target, false));
167
+ },
168
+ useCaseSensitiveFileNames: function useCaseSensitiveFileNames() {
169
+ return sys.useCaseSensitiveFileNames;
170
+ }
171
+ }),
172
+ updateFile: function updateFile(sourceFile) {
173
+ var alreadyExists = sourceFiles.has(sourceFile.fileName);
174
+ sys.writeFile(sourceFile.fileName, sourceFile.text);
175
+ sourceFiles.set(sourceFile.fileName, sourceFile);
176
+ return alreadyExists;
177
+ },
178
+ deleteFile: function deleteFile(sourceFile) {
179
+ var alreadyExists = sourceFiles.has(sourceFile.fileName);
180
+ sourceFiles["delete"](sourceFile.fileName);
181
+ sys.deleteFile(sourceFile.fileName);
182
+ return alreadyExists;
183
+ }
184
+ };
185
+ return vHost;
186
+ }
187
+ var requirePath = function requirePath2() {
188
+ return __require(String.fromCharCode(112, 97, 116, 104));
189
+ };
190
+
191
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
12
192
  import os from "os";
13
193
 
14
194
  // source/unplugin/constants.mjs
@@ -187,7 +367,7 @@ var rawPlugin = (options = {}, meta) => {
187
367
  async buildEnd(useConfigFileNames = false) {
188
368
  if (transformTS) {
189
369
  const ts2 = await tsPromise;
190
- const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts2);
370
+ const system = createFSBackedSystem(fsMap, process.cwd(), ts2);
191
371
  const {
192
372
  fileExists: systemFileExists,
193
373
  readFile: systemReadFile,
@@ -248,7 +428,7 @@ var rawPlugin = (options = {}, meta) => {
248
428
  sourceMaps.set(filename, sourceMap);
249
429
  return compiledTS;
250
430
  };
251
- const host = tsvfs.createVirtualCompilerHost(
431
+ const host = createVirtualCompilerHost(
252
432
  system,
253
433
  compilerOptions,
254
434
  ts2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.11.2",
4
+ "version": "0.11.3",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",
@@ -95,6 +95,7 @@
95
95
  },
96
96
  "scripts": {
97
97
  "build": "bash ./build/build.sh",
98
+ "build:self": "yarn build && bash ./build/build-self.sh",
98
99
  "docs:dev": "yarn build && vitepress dev civet.dev",
99
100
  "docs:build": "yarn build && vitepress build civet.dev",
100
101
  "docs:preview": "yarn build && vitepress preview civet.dev",
@@ -107,7 +108,6 @@
107
108
  "license": "MIT",
108
109
  "dependencies": {
109
110
  "@cspotcode/source-map-support": "^0.8.1",
110
- "@typescript/vfs": "^1.6.0",
111
111
  "unplugin": "^2.3.2"
112
112
  },
113
113
  "devDependencies": {
@@ -117,6 +117,7 @@
117
117
  "@types/assert": "^1.5.6",
118
118
  "@types/mocha": "^10.0.8",
119
119
  "@types/node": "^22.10.2",
120
+ "@typescript/vfs": "^1.6.0",
120
121
  "c8": "^7.12.0",
121
122
  "esbuild": "0.24.0",
122
123
  "marked": "^4.2.4",
@@ -137,6 +138,9 @@
137
138
  "yaml": "^2.4.5"
138
139
  },
139
140
  "peerDependenciesMeta": {
141
+ "typescript": {
142
+ "optional": true
143
+ },
140
144
  "yaml": {
141
145
  "optional": true
142
146
  }