@danielx/civet 0.11.2 → 0.11.4

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.
@@ -40,7 +40,180 @@ var import_config = require("@danielx/civet/config");
40
40
  var import_ts_diagnostic = require("@danielx/civet/ts-diagnostic");
41
41
  var fs = __toESM(require("fs"));
42
42
  var import_path = __toESM(require("path"));
43
- var tsvfs = __toESM(require("@typescript/vfs"));
43
+
44
+ // node_modules/@typescript/vfs/dist/vfs.esm.js
45
+ function _extends() {
46
+ _extends = Object.assign ? Object.assign.bind() : function(target) {
47
+ for (var i = 1; i < arguments.length; i++) {
48
+ var source = arguments[i];
49
+ for (var key in source) {
50
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
51
+ target[key] = source[key];
52
+ }
53
+ }
54
+ }
55
+ return target;
56
+ };
57
+ return _extends.apply(this, arguments);
58
+ }
59
+ var hasLocalStorage = false;
60
+ try {
61
+ hasLocalStorage = typeof localStorage !== "undefined";
62
+ } catch (error) {
63
+ }
64
+ var hasProcess = typeof process !== "undefined";
65
+ var shouldDebug = hasLocalStorage && /* @__PURE__ */ localStorage.getItem("DEBUG") || hasProcess && process.env.DEBUG;
66
+ var debugLog = shouldDebug ? console.log : function(_message) {
67
+ return "";
68
+ };
69
+ function notImplemented(methodName) {
70
+ throw new Error("Method '" + methodName + "' is not implemented.");
71
+ }
72
+ function audit(name, fn) {
73
+ return function() {
74
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
75
+ args[_key] = arguments[_key];
76
+ }
77
+ var res = fn.apply(void 0, args);
78
+ var smallres = typeof res === "string" ? res.slice(0, 80) + "..." : res;
79
+ debugLog.apply(void 0, ["> " + name].concat(args));
80
+ debugLog("< " + smallres);
81
+ return res;
82
+ };
83
+ }
84
+ var defaultCompilerOptions = function defaultCompilerOptions2(ts) {
85
+ return _extends({}, ts.getDefaultCompilerOptions(), {
86
+ jsx: ts.JsxEmit.React,
87
+ strict: true,
88
+ esModuleInterop: true,
89
+ module: ts.ModuleKind.ESNext,
90
+ suppressOutputPathCheck: true,
91
+ skipLibCheck: true,
92
+ skipDefaultLibCheck: true,
93
+ moduleResolution: ts.ModuleResolutionKind.NodeJs
94
+ });
95
+ };
96
+ function createFSBackedSystem(files, _projectRoot, ts, tsLibDirectory) {
97
+ var root = _projectRoot + "/vfs";
98
+ var path2 = requirePath();
99
+ var nodeSys = ts.sys;
100
+ var tsLib = tsLibDirectory != null ? tsLibDirectory : path2.dirname(require.resolve("typescript"));
101
+ return {
102
+ // @ts-ignore
103
+ name: "fs-vfs",
104
+ root,
105
+ args: [],
106
+ createDirectory: function createDirectory() {
107
+ return notImplemented("createDirectory");
108
+ },
109
+ // TODO: could make a real file tree
110
+ directoryExists: audit("directoryExists", function(directory) {
111
+ return Array.from(files.keys()).some(function(path3) {
112
+ return path3.startsWith(directory);
113
+ }) || nodeSys.directoryExists(directory);
114
+ }),
115
+ exit: nodeSys.exit,
116
+ fileExists: audit("fileExists", function(fileName) {
117
+ if (files.has(fileName)) return true;
118
+ if (fileName.includes("tsconfig.json") || fileName.includes("tsconfig.json")) return false;
119
+ if (fileName.startsWith("/lib")) {
120
+ var tsLibName = tsLib + "/" + fileName.replace("/", "");
121
+ return nodeSys.fileExists(tsLibName);
122
+ }
123
+ return nodeSys.fileExists(fileName);
124
+ }),
125
+ getCurrentDirectory: function getCurrentDirectory() {
126
+ return root;
127
+ },
128
+ getDirectories: nodeSys.getDirectories,
129
+ getExecutingFilePath: function getExecutingFilePath() {
130
+ return notImplemented("getExecutingFilePath");
131
+ },
132
+ readDirectory: audit("readDirectory", function() {
133
+ if ((arguments.length <= 0 ? void 0 : arguments[0]) === "/") {
134
+ return Array.from(files.keys());
135
+ } else {
136
+ return nodeSys.readDirectory.apply(nodeSys, arguments);
137
+ }
138
+ }),
139
+ readFile: audit("readFile", function(fileName) {
140
+ if (files.has(fileName)) return files.get(fileName);
141
+ if (fileName.startsWith("/lib")) {
142
+ var tsLibName = tsLib + "/" + fileName.replace("/", "");
143
+ var result = nodeSys.readFile(tsLibName);
144
+ if (!result) {
145
+ var libs = nodeSys.readDirectory(tsLib);
146
+ 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 + ".");
147
+ }
148
+ return result;
149
+ }
150
+ return nodeSys.readFile(fileName);
151
+ }),
152
+ resolvePath: function resolvePath(path3) {
153
+ if (files.has(path3)) return path3;
154
+ return nodeSys.resolvePath(path3);
155
+ },
156
+ newLine: "\n",
157
+ useCaseSensitiveFileNames: true,
158
+ write: function write() {
159
+ return notImplemented("write");
160
+ },
161
+ writeFile: function writeFile(fileName, contents) {
162
+ files.set(fileName, contents);
163
+ },
164
+ deleteFile: function deleteFile(fileName) {
165
+ files["delete"](fileName);
166
+ },
167
+ realpath: nodeSys.realpath
168
+ };
169
+ }
170
+ function createVirtualCompilerHost(sys, compilerOptions, ts) {
171
+ var sourceFiles = /* @__PURE__ */ new Map();
172
+ var save = function save2(sourceFile) {
173
+ sourceFiles.set(sourceFile.fileName, sourceFile);
174
+ return sourceFile;
175
+ };
176
+ var vHost = {
177
+ compilerHost: _extends({}, sys, {
178
+ getCanonicalFileName: function getCanonicalFileName(fileName) {
179
+ return fileName;
180
+ },
181
+ getDefaultLibFileName: function getDefaultLibFileName() {
182
+ return "/" + ts.getDefaultLibFileName(compilerOptions);
183
+ },
184
+ // '/lib.d.ts',
185
+ // getDefaultLibLocation: () => '/',
186
+ getNewLine: function getNewLine() {
187
+ return sys.newLine;
188
+ },
189
+ getSourceFile: function getSourceFile(fileName, languageVersionOrOptions) {
190
+ var _ref;
191
+ return sourceFiles.get(fileName) || save(ts.createSourceFile(fileName, sys.readFile(fileName), (_ref = languageVersionOrOptions != null ? languageVersionOrOptions : compilerOptions.target) != null ? _ref : defaultCompilerOptions(ts).target, false));
192
+ },
193
+ useCaseSensitiveFileNames: function useCaseSensitiveFileNames() {
194
+ return sys.useCaseSensitiveFileNames;
195
+ }
196
+ }),
197
+ updateFile: function updateFile(sourceFile) {
198
+ var alreadyExists = sourceFiles.has(sourceFile.fileName);
199
+ sys.writeFile(sourceFile.fileName, sourceFile.text);
200
+ sourceFiles.set(sourceFile.fileName, sourceFile);
201
+ return alreadyExists;
202
+ },
203
+ deleteFile: function deleteFile(sourceFile) {
204
+ var alreadyExists = sourceFiles.has(sourceFile.fileName);
205
+ sourceFiles["delete"](sourceFile.fileName);
206
+ sys.deleteFile(sourceFile.fileName);
207
+ return alreadyExists;
208
+ }
209
+ };
210
+ return vHost;
211
+ }
212
+ var requirePath = function requirePath2() {
213
+ return require(String.fromCharCode(112, 97, 116, 104));
214
+ };
215
+
216
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
44
217
  var import_os = __toESM(require("os"));
45
218
 
46
219
  // source/unplugin/constants.mjs
@@ -219,7 +392,7 @@ var rawPlugin = (options = {}, meta) => {
219
392
  async buildEnd(useConfigFileNames = false) {
220
393
  if (transformTS) {
221
394
  const ts2 = await tsPromise;
222
- const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts2);
395
+ const system = createFSBackedSystem(fsMap, process.cwd(), ts2);
223
396
  const {
224
397
  fileExists: systemFileExists,
225
398
  readFile: systemReadFile,
@@ -280,7 +453,7 @@ var rawPlugin = (options = {}, meta) => {
280
453
  sourceMaps.set(filename, sourceMap);
281
454
  return compiledTS;
282
455
  };
283
- const host = tsvfs.createVirtualCompilerHost(
456
+ const host = createVirtualCompilerHost(
284
457
  system,
285
458
  compilerOptions,
286
459
  ts2
@@ -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.4",
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
  }