@atscript/core 0.1.56 → 0.1.58
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/index.cjs +162 -152
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +162 -153
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -27,9 +27,9 @@ const node_fs_promises = __toESM(require("node:fs/promises"));
|
|
|
27
27
|
const node_path = __toESM(require("node:path"));
|
|
28
28
|
const node_url = __toESM(require("node:url"));
|
|
29
29
|
const rolldown = __toESM(require("rolldown"));
|
|
30
|
-
const __prostojs_parser = __toESM(require("@prostojs/parser"));
|
|
31
30
|
const path = __toESM(require("path"));
|
|
32
31
|
const url = __toESM(require("url"));
|
|
32
|
+
const __prostojs_parser = __toESM(require("@prostojs/parser"));
|
|
33
33
|
const defu = __toESM(require("defu"));
|
|
34
34
|
const fs_promises = __toESM(require("fs/promises"));
|
|
35
35
|
const glob = __toESM(require("glob"));
|
|
@@ -1096,6 +1096,161 @@ function defineConfig(config) {
|
|
|
1096
1096
|
return config;
|
|
1097
1097
|
}
|
|
1098
1098
|
|
|
1099
|
+
//#endregion
|
|
1100
|
+
//#region packages/core/src/resolve-bare.ts
|
|
1101
|
+
function isBareSpecifier(specifier) {
|
|
1102
|
+
return specifier[0] !== "." && specifier[0] !== "/";
|
|
1103
|
+
}
|
|
1104
|
+
function isBareId(id) {
|
|
1105
|
+
return id.startsWith("bare:");
|
|
1106
|
+
}
|
|
1107
|
+
function parseBareSpecifier(specifier) {
|
|
1108
|
+
if (specifier.startsWith("@")) {
|
|
1109
|
+
const firstSlash$1 = specifier.indexOf("/");
|
|
1110
|
+
if (firstSlash$1 === -1) return {
|
|
1111
|
+
packageName: specifier,
|
|
1112
|
+
subpath: "."
|
|
1113
|
+
};
|
|
1114
|
+
const secondSlash = specifier.indexOf("/", firstSlash$1 + 1);
|
|
1115
|
+
if (secondSlash === -1) return {
|
|
1116
|
+
packageName: specifier,
|
|
1117
|
+
subpath: "."
|
|
1118
|
+
};
|
|
1119
|
+
return {
|
|
1120
|
+
packageName: specifier.slice(0, secondSlash),
|
|
1121
|
+
subpath: `./${specifier.slice(secondSlash + 1)}`
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
const firstSlash = specifier.indexOf("/");
|
|
1125
|
+
if (firstSlash === -1) return {
|
|
1126
|
+
packageName: specifier,
|
|
1127
|
+
subpath: "."
|
|
1128
|
+
};
|
|
1129
|
+
return {
|
|
1130
|
+
packageName: specifier.slice(0, firstSlash),
|
|
1131
|
+
subpath: `./${specifier.slice(firstSlash + 1)}`
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
function resolvePackageExports(exports$1, subpath) {
|
|
1135
|
+
if (!exports$1 || typeof exports$1 !== "object") return undefined;
|
|
1136
|
+
const exportsMap = exports$1;
|
|
1137
|
+
const subpathWithExt = subpath === "." ? "." : `${subpath}.as`;
|
|
1138
|
+
const entry = exportsMap[subpathWithExt];
|
|
1139
|
+
if (entry) return resolveExportEntry(entry);
|
|
1140
|
+
for (const [pattern, value] of Object.entries(exportsMap)) {
|
|
1141
|
+
if (!pattern.includes("*")) continue;
|
|
1142
|
+
const match = matchSubpathPattern(pattern, subpathWithExt);
|
|
1143
|
+
if (match !== undefined) {
|
|
1144
|
+
const resolved = resolveExportEntry(value);
|
|
1145
|
+
if (resolved) return resolved.replaceAll("*", match);
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
return undefined;
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* Resolve a single export entry, checking for `atscript` condition.
|
|
1152
|
+
*/ function resolveExportEntry(entry) {
|
|
1153
|
+
if (typeof entry === "string") return entry;
|
|
1154
|
+
if (entry && typeof entry === "object") {
|
|
1155
|
+
const obj = entry;
|
|
1156
|
+
if (typeof obj["atscript"] === "string") return obj["atscript"];
|
|
1157
|
+
if (typeof obj["default"] === "string") return obj["default"];
|
|
1158
|
+
}
|
|
1159
|
+
return undefined;
|
|
1160
|
+
}
|
|
1161
|
+
/**
|
|
1162
|
+
* Match a subpath against a pattern with a single `*` wildcard.
|
|
1163
|
+
* Returns the matched wildcard portion, or undefined if no match.
|
|
1164
|
+
*/ function matchSubpathPattern(pattern, subpath) {
|
|
1165
|
+
const starIdx = pattern.indexOf("*");
|
|
1166
|
+
if (starIdx === -1) return undefined;
|
|
1167
|
+
const prefix = pattern.slice(0, starIdx);
|
|
1168
|
+
const suffix = pattern.slice(starIdx + 1);
|
|
1169
|
+
if (subpath.startsWith(prefix) && subpath.endsWith(suffix) && subpath.length >= prefix.length + suffix.length) return subpath.slice(prefix.length, subpath.length - suffix.length);
|
|
1170
|
+
return undefined;
|
|
1171
|
+
}
|
|
1172
|
+
/**
|
|
1173
|
+
* Check if a file exists.
|
|
1174
|
+
*/ async function fileExists(filePath) {
|
|
1175
|
+
try {
|
|
1176
|
+
await (0, node_fs_promises.access)(filePath);
|
|
1177
|
+
return true;
|
|
1178
|
+
} catch {
|
|
1179
|
+
return false;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
const resolveCache = new Map();
|
|
1183
|
+
function clearResolveBareCache() {
|
|
1184
|
+
resolveCache.clear();
|
|
1185
|
+
}
|
|
1186
|
+
async function resolveBareSpecifier(specifier, fromDir) {
|
|
1187
|
+
const cacheKey = `${fromDir}\0${specifier}`;
|
|
1188
|
+
if (resolveCache.has(cacheKey)) return resolveCache.get(cacheKey);
|
|
1189
|
+
const result = await _resolveBareSpecifier(specifier, fromDir);
|
|
1190
|
+
resolveCache.set(cacheKey, result);
|
|
1191
|
+
return result;
|
|
1192
|
+
}
|
|
1193
|
+
async function _resolveBareSpecifier(specifier, fromDir) {
|
|
1194
|
+
const { packageName, subpath } = parseBareSpecifier(specifier);
|
|
1195
|
+
let dir = fromDir;
|
|
1196
|
+
const root$1 = node_path.default.parse(dir).root;
|
|
1197
|
+
while (true) {
|
|
1198
|
+
const pkgDir = node_path.default.join(dir, "node_modules", packageName);
|
|
1199
|
+
const pkgJsonPath = node_path.default.join(pkgDir, "package.json");
|
|
1200
|
+
if (await fileExists(pkgJsonPath)) {
|
|
1201
|
+
try {
|
|
1202
|
+
const pkgJson = JSON.parse(await (0, node_fs_promises.readFile)(pkgJsonPath, "utf8"));
|
|
1203
|
+
if (pkgJson.exports) {
|
|
1204
|
+
const resolved = resolvePackageExports(pkgJson.exports, subpath);
|
|
1205
|
+
if (resolved) {
|
|
1206
|
+
const fullPath = node_path.default.resolve(pkgDir, resolved);
|
|
1207
|
+
if (await fileExists(fullPath)) return resolveRealPath(fullPath);
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
} catch {}
|
|
1211
|
+
const directPath = subpath === "." ? node_path.default.join(pkgDir, "index.as") : node_path.default.join(pkgDir, `${subpath.slice(2)}.as`);
|
|
1212
|
+
if (await fileExists(directPath)) return resolveRealPath(directPath);
|
|
1213
|
+
}
|
|
1214
|
+
const parentDir = node_path.default.dirname(dir);
|
|
1215
|
+
if (parentDir === dir || dir === root$1) break;
|
|
1216
|
+
dir = parentDir;
|
|
1217
|
+
}
|
|
1218
|
+
return undefined;
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Resolve symlinks to get the canonical path (important for pnpm).
|
|
1222
|
+
*/ async function resolveRealPath(filePath) {
|
|
1223
|
+
try {
|
|
1224
|
+
return await (0, node_fs_promises.realpath)(filePath);
|
|
1225
|
+
} catch {
|
|
1226
|
+
return filePath;
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
//#endregion
|
|
1231
|
+
//#region packages/core/src/parser/utils.ts
|
|
1232
|
+
function resolveAtscriptFromPath(from, id) {
|
|
1233
|
+
if (isBareSpecifier(from)) return `bare:${from}.as`;
|
|
1234
|
+
return `file://${path.default.join(fileUriToPath(id).split("/").slice(0, -1).join("/"), from)}.as`;
|
|
1235
|
+
}
|
|
1236
|
+
function fileUriToPath(id) {
|
|
1237
|
+
if (!id.startsWith("file://")) return id;
|
|
1238
|
+
const raw = id.slice(7);
|
|
1239
|
+
try {
|
|
1240
|
+
return decodeURIComponent(raw);
|
|
1241
|
+
} catch {
|
|
1242
|
+
return raw;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
function getRelPath(fromUri, toUri) {
|
|
1246
|
+
const fromPath = new url.URL(fromUri).pathname;
|
|
1247
|
+
const toPath = new url.URL(toUri).pathname;
|
|
1248
|
+
const relPath = path.default.relative(path.default.dirname(fromPath), toPath);
|
|
1249
|
+
const { dir, name } = path.default.parse(relPath);
|
|
1250
|
+
const prefix = dir.startsWith("..") ? "" : "./";
|
|
1251
|
+
return `${prefix}${dir ? `${dir}/` : ""}${name}`;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1099
1254
|
//#endregion
|
|
1100
1255
|
//#region packages/core/src/config/load-config.ts
|
|
1101
1256
|
async function bundleTsConfig(configFile, forceFormat) {
|
|
@@ -1105,6 +1260,7 @@ async function bundleTsConfig(configFile, forceFormat) {
|
|
|
1105
1260
|
const bundle = await (0, rolldown.rolldown)({
|
|
1106
1261
|
input: configFile,
|
|
1107
1262
|
platform: "node",
|
|
1263
|
+
tsconfig: false,
|
|
1108
1264
|
resolve: { mainFields: ["main"] },
|
|
1109
1265
|
transform: { define: {
|
|
1110
1266
|
"__dirname": dirnameVarName,
|
|
@@ -1166,8 +1322,7 @@ async function resolveConfigFile(docUri, _root) {
|
|
|
1166
1322
|
return undefined;
|
|
1167
1323
|
}
|
|
1168
1324
|
async function findConfigFileName(d) {
|
|
1169
|
-
const
|
|
1170
|
-
const filesInWorkingDirectory = new Set(await (0, node_fs_promises.readdir)(decodeURIComponent(p)));
|
|
1325
|
+
const filesInWorkingDirectory = new Set(await (0, node_fs_promises.readdir)(fileUriToPath(d)));
|
|
1171
1326
|
for (const extension of SUPPORTED_CONFIG_FORMATS) {
|
|
1172
1327
|
const fileName = `${DEFAULT_CONFIG_BASE}${extension}`;
|
|
1173
1328
|
if (filesInWorkingDirectory.has(fileName)) return fileName;
|
|
@@ -2896,152 +3051,6 @@ var TSeverity = /*#__PURE__*/ function(TSeverity$1) {
|
|
|
2896
3051
|
return TSeverity$1;
|
|
2897
3052
|
}({});
|
|
2898
3053
|
|
|
2899
|
-
//#endregion
|
|
2900
|
-
//#region packages/core/src/resolve-bare.ts
|
|
2901
|
-
function isBareSpecifier(specifier) {
|
|
2902
|
-
return specifier[0] !== "." && specifier[0] !== "/";
|
|
2903
|
-
}
|
|
2904
|
-
function isBareId(id) {
|
|
2905
|
-
return id.startsWith("bare:");
|
|
2906
|
-
}
|
|
2907
|
-
function parseBareSpecifier(specifier) {
|
|
2908
|
-
if (specifier.startsWith("@")) {
|
|
2909
|
-
const firstSlash$1 = specifier.indexOf("/");
|
|
2910
|
-
if (firstSlash$1 === -1) return {
|
|
2911
|
-
packageName: specifier,
|
|
2912
|
-
subpath: "."
|
|
2913
|
-
};
|
|
2914
|
-
const secondSlash = specifier.indexOf("/", firstSlash$1 + 1);
|
|
2915
|
-
if (secondSlash === -1) return {
|
|
2916
|
-
packageName: specifier,
|
|
2917
|
-
subpath: "."
|
|
2918
|
-
};
|
|
2919
|
-
return {
|
|
2920
|
-
packageName: specifier.slice(0, secondSlash),
|
|
2921
|
-
subpath: `./${specifier.slice(secondSlash + 1)}`
|
|
2922
|
-
};
|
|
2923
|
-
}
|
|
2924
|
-
const firstSlash = specifier.indexOf("/");
|
|
2925
|
-
if (firstSlash === -1) return {
|
|
2926
|
-
packageName: specifier,
|
|
2927
|
-
subpath: "."
|
|
2928
|
-
};
|
|
2929
|
-
return {
|
|
2930
|
-
packageName: specifier.slice(0, firstSlash),
|
|
2931
|
-
subpath: `./${specifier.slice(firstSlash + 1)}`
|
|
2932
|
-
};
|
|
2933
|
-
}
|
|
2934
|
-
function resolvePackageExports(exports$1, subpath) {
|
|
2935
|
-
if (!exports$1 || typeof exports$1 !== "object") return undefined;
|
|
2936
|
-
const exportsMap = exports$1;
|
|
2937
|
-
const subpathWithExt = subpath === "." ? "." : `${subpath}.as`;
|
|
2938
|
-
const entry = exportsMap[subpathWithExt];
|
|
2939
|
-
if (entry) return resolveExportEntry(entry);
|
|
2940
|
-
for (const [pattern, value] of Object.entries(exportsMap)) {
|
|
2941
|
-
if (!pattern.includes("*")) continue;
|
|
2942
|
-
const match = matchSubpathPattern(pattern, subpathWithExt);
|
|
2943
|
-
if (match !== undefined) {
|
|
2944
|
-
const resolved = resolveExportEntry(value);
|
|
2945
|
-
if (resolved) return resolved.replaceAll("*", match);
|
|
2946
|
-
}
|
|
2947
|
-
}
|
|
2948
|
-
return undefined;
|
|
2949
|
-
}
|
|
2950
|
-
/**
|
|
2951
|
-
* Resolve a single export entry, checking for `atscript` condition.
|
|
2952
|
-
*/ function resolveExportEntry(entry) {
|
|
2953
|
-
if (typeof entry === "string") return entry;
|
|
2954
|
-
if (entry && typeof entry === "object") {
|
|
2955
|
-
const obj = entry;
|
|
2956
|
-
if (typeof obj["atscript"] === "string") return obj["atscript"];
|
|
2957
|
-
if (typeof obj["default"] === "string") return obj["default"];
|
|
2958
|
-
}
|
|
2959
|
-
return undefined;
|
|
2960
|
-
}
|
|
2961
|
-
/**
|
|
2962
|
-
* Match a subpath against a pattern with a single `*` wildcard.
|
|
2963
|
-
* Returns the matched wildcard portion, or undefined if no match.
|
|
2964
|
-
*/ function matchSubpathPattern(pattern, subpath) {
|
|
2965
|
-
const starIdx = pattern.indexOf("*");
|
|
2966
|
-
if (starIdx === -1) return undefined;
|
|
2967
|
-
const prefix = pattern.slice(0, starIdx);
|
|
2968
|
-
const suffix = pattern.slice(starIdx + 1);
|
|
2969
|
-
if (subpath.startsWith(prefix) && subpath.endsWith(suffix) && subpath.length >= prefix.length + suffix.length) return subpath.slice(prefix.length, subpath.length - suffix.length);
|
|
2970
|
-
return undefined;
|
|
2971
|
-
}
|
|
2972
|
-
/**
|
|
2973
|
-
* Check if a file exists.
|
|
2974
|
-
*/ async function fileExists(filePath) {
|
|
2975
|
-
try {
|
|
2976
|
-
await (0, node_fs_promises.access)(filePath);
|
|
2977
|
-
return true;
|
|
2978
|
-
} catch {
|
|
2979
|
-
return false;
|
|
2980
|
-
}
|
|
2981
|
-
}
|
|
2982
|
-
const resolveCache = new Map();
|
|
2983
|
-
function clearResolveBareCache() {
|
|
2984
|
-
resolveCache.clear();
|
|
2985
|
-
}
|
|
2986
|
-
async function resolveBareSpecifier(specifier, fromDir) {
|
|
2987
|
-
const cacheKey = `${fromDir}\0${specifier}`;
|
|
2988
|
-
if (resolveCache.has(cacheKey)) return resolveCache.get(cacheKey);
|
|
2989
|
-
const result = await _resolveBareSpecifier(specifier, fromDir);
|
|
2990
|
-
resolveCache.set(cacheKey, result);
|
|
2991
|
-
return result;
|
|
2992
|
-
}
|
|
2993
|
-
async function _resolveBareSpecifier(specifier, fromDir) {
|
|
2994
|
-
const { packageName, subpath } = parseBareSpecifier(specifier);
|
|
2995
|
-
let dir = fromDir;
|
|
2996
|
-
const root$1 = node_path.default.parse(dir).root;
|
|
2997
|
-
while (true) {
|
|
2998
|
-
const pkgDir = node_path.default.join(dir, "node_modules", packageName);
|
|
2999
|
-
const pkgJsonPath = node_path.default.join(pkgDir, "package.json");
|
|
3000
|
-
if (await fileExists(pkgJsonPath)) {
|
|
3001
|
-
try {
|
|
3002
|
-
const pkgJson = JSON.parse(await (0, node_fs_promises.readFile)(pkgJsonPath, "utf8"));
|
|
3003
|
-
if (pkgJson.exports) {
|
|
3004
|
-
const resolved = resolvePackageExports(pkgJson.exports, subpath);
|
|
3005
|
-
if (resolved) {
|
|
3006
|
-
const fullPath = node_path.default.resolve(pkgDir, resolved);
|
|
3007
|
-
if (await fileExists(fullPath)) return resolveRealPath(fullPath);
|
|
3008
|
-
}
|
|
3009
|
-
}
|
|
3010
|
-
} catch {}
|
|
3011
|
-
const directPath = subpath === "." ? node_path.default.join(pkgDir, "index.as") : node_path.default.join(pkgDir, `${subpath.slice(2)}.as`);
|
|
3012
|
-
if (await fileExists(directPath)) return resolveRealPath(directPath);
|
|
3013
|
-
}
|
|
3014
|
-
const parentDir = node_path.default.dirname(dir);
|
|
3015
|
-
if (parentDir === dir || dir === root$1) break;
|
|
3016
|
-
dir = parentDir;
|
|
3017
|
-
}
|
|
3018
|
-
return undefined;
|
|
3019
|
-
}
|
|
3020
|
-
/**
|
|
3021
|
-
* Resolve symlinks to get the canonical path (important for pnpm).
|
|
3022
|
-
*/ async function resolveRealPath(filePath) {
|
|
3023
|
-
try {
|
|
3024
|
-
return await (0, node_fs_promises.realpath)(filePath);
|
|
3025
|
-
} catch {
|
|
3026
|
-
return filePath;
|
|
3027
|
-
}
|
|
3028
|
-
}
|
|
3029
|
-
|
|
3030
|
-
//#endregion
|
|
3031
|
-
//#region packages/core/src/parser/utils.ts
|
|
3032
|
-
function resolveAtscriptFromPath(from, id) {
|
|
3033
|
-
if (isBareSpecifier(from)) return `bare:${from}.as`;
|
|
3034
|
-
return `file://${path.default.join(id.slice(7).split("/").slice(0, -1).join("/"), from)}.as`;
|
|
3035
|
-
}
|
|
3036
|
-
function getRelPath(fromUri, toUri) {
|
|
3037
|
-
const fromPath = new url.URL(fromUri).pathname;
|
|
3038
|
-
const toPath = new url.URL(toUri).pathname;
|
|
3039
|
-
const relPath = path.default.relative(path.default.dirname(fromPath), toPath);
|
|
3040
|
-
const { dir, name } = path.default.parse(relPath);
|
|
3041
|
-
const prefix = dir.startsWith("..") ? "" : "./";
|
|
3042
|
-
return `${prefix}${dir ? `${dir}/` : ""}${name}`;
|
|
3043
|
-
}
|
|
3044
|
-
|
|
3045
3054
|
//#endregion
|
|
3046
3055
|
//#region packages/core/src/token-index/blocks-index.ts
|
|
3047
3056
|
function _define_property$5(obj, key, value) {
|
|
@@ -4836,7 +4845,7 @@ var PluginManager = class {
|
|
|
4836
4845
|
return newId;
|
|
4837
4846
|
}
|
|
4838
4847
|
async load(id) {
|
|
4839
|
-
const filePath =
|
|
4848
|
+
const filePath = fileUriToPath(id);
|
|
4840
4849
|
for (const plugin of this.plugins) if (plugin.load) {
|
|
4841
4850
|
const content = await plugin.load(id);
|
|
4842
4851
|
if (content) return content;
|
|
@@ -4847,7 +4856,7 @@ var PluginManager = class {
|
|
|
4847
4856
|
for (const plugin of this.plugins) if (plugin.onDocument) await plugin.onDocument(doc);
|
|
4848
4857
|
}
|
|
4849
4858
|
async render(doc, format) {
|
|
4850
|
-
const source =
|
|
4859
|
+
const source = fileUriToPath(doc.id);
|
|
4851
4860
|
const files = [];
|
|
4852
4861
|
for (const plugin of this.plugins) if (plugin.render) {
|
|
4853
4862
|
const newFiles = await plugin.render(doc, format);
|
|
@@ -5073,7 +5082,7 @@ else types.push({ type: "boolean" });
|
|
|
5073
5082
|
async checkImport(atscript, from, imports, checked) {
|
|
5074
5083
|
let forId = resolveAtscriptFromPath(from.text, atscript.id);
|
|
5075
5084
|
if (isBareId(forId)) {
|
|
5076
|
-
const fromDir = atscript.id
|
|
5085
|
+
const fromDir = fileUriToPath(atscript.id).split("/").slice(0, -1).join("/");
|
|
5077
5086
|
const resolved = await resolveBareSpecifier(from.text, fromDir);
|
|
5078
5087
|
if (!resolved) {
|
|
5079
5088
|
atscript.registerMessages([{
|
|
@@ -5510,6 +5519,7 @@ exports.build = build
|
|
|
5510
5519
|
exports.clearResolveBareCache = clearResolveBareCache
|
|
5511
5520
|
exports.createAtscriptPlugin = createAtscriptPlugin
|
|
5512
5521
|
exports.defineConfig = defineConfig
|
|
5522
|
+
exports.fileUriToPath = fileUriToPath
|
|
5513
5523
|
exports.flattenInterfaceNode = flattenInterfaceNode
|
|
5514
5524
|
exports.getFieldsForType = getFieldsForType
|
|
5515
5525
|
exports.getQueryCompletionScope = getQueryCompletionScope
|
package/dist/index.d.ts
CHANGED
|
@@ -861,6 +861,7 @@ declare function isAnnotationSpec(a?: TAnnotationsTree | AnnotationSpec): a is A
|
|
|
861
861
|
declare function resolveAnnotation(name: string, annotationsTree?: TAnnotationsTree): AnnotationSpec | undefined;
|
|
862
862
|
|
|
863
863
|
declare function resolveAtscriptFromPath(from: string, id: string): string;
|
|
864
|
+
declare function fileUriToPath(id: string): string;
|
|
864
865
|
declare function getRelPath(fromUri: string, toUri: string): string;
|
|
865
866
|
|
|
866
867
|
/**
|
|
@@ -1005,5 +1006,5 @@ type TQueryCursorContext = {
|
|
|
1005
1006
|
*/
|
|
1006
1007
|
declare function analyzeQueryCursorContext(textBeforeCursor: string): TQueryCursorContext;
|
|
1007
1008
|
|
|
1008
|
-
export { $n, AnnotationSpec, AtscriptDoc, AtscriptRepo, BuildRepo, DEFAULT_FORMAT, PluginManager, SemanticAnnotateNode, SemanticArrayNode, SemanticConstNode, SemanticGroup, SemanticImportNode, SemanticInterfaceNode, SemanticNode, SemanticPrimitiveNode, SemanticPropNode, SemanticQueryComparisonNode, SemanticQueryFieldRefNode, SemanticQueryLogicalNode, SemanticQueryNode, SemanticQueryValueListNode, SemanticQueryValueNode, SemanticRefNode, SemanticStructureNode, SemanticTupleNode, SemanticTypeNode, Token, analyzeQueryCursorContext, build, clearResolveBareCache, createAtscriptPlugin, defineConfig, flattenInterfaceNode, getFieldsForType, getQueryCompletionScope, getQueryScope, getRelPath, hasNavPropAnnotation, isAnnotate, isAnnotationSpec, isArray, isBareId, isBareSpecifier, isConst, isGroup, isImport, isInterface, isPhantomNode, isPrimitive, isProp, isQueryComparison, isQueryFieldRef, isQueryLogical, isRef, isStructure, isTuple, isType, loadConfig, loadTsConfig, parseBareSpecifier, resolveAnnotation, resolveAtscriptFromPath, resolveBareSpecifier, resolveConfigFile, resolveQueryFieldRef };
|
|
1009
|
+
export { $n, AnnotationSpec, AtscriptDoc, AtscriptRepo, BuildRepo, DEFAULT_FORMAT, PluginManager, SemanticAnnotateNode, SemanticArrayNode, SemanticConstNode, SemanticGroup, SemanticImportNode, SemanticInterfaceNode, SemanticNode, SemanticPrimitiveNode, SemanticPropNode, SemanticQueryComparisonNode, SemanticQueryFieldRefNode, SemanticQueryLogicalNode, SemanticQueryNode, SemanticQueryValueListNode, SemanticQueryValueNode, SemanticRefNode, SemanticStructureNode, SemanticTupleNode, SemanticTypeNode, Token, analyzeQueryCursorContext, build, clearResolveBareCache, createAtscriptPlugin, defineConfig, fileUriToPath, flattenInterfaceNode, getFieldsForType, getQueryCompletionScope, getQueryScope, getRelPath, hasNavPropAnnotation, isAnnotate, isAnnotationSpec, isArray, isBareId, isBareSpecifier, isConst, isGroup, isImport, isInterface, isPhantomNode, isPrimitive, isProp, isQueryComparison, isQueryFieldRef, isQueryLogical, isRef, isStructure, isTuple, isType, loadConfig, loadTsConfig, parseBareSpecifier, resolveAnnotation, resolveAtscriptFromPath, resolveBareSpecifier, resolveConfigFile, resolveQueryFieldRef };
|
|
1009
1010
|
export type { SemanticQueryExprNode, TAnnotationArgument, TAnnotationSpecConfig, TAnnotationTokens, TAnnotationsTree, TAtscriptConfig, TAtscriptConfigInput, TAtscriptConfigOutput, TAtscriptDocConfig, TAtscriptPlugin, TAtscriptRenderFormat, TDbConfig, TDbConfigDeclarative, TFlatFieldDescriptor, TFlattenOptions, TMessages, TNodeEntity, TOutput, TOutputWithSource, TPluginManagers, TPluginOutput, TPrimitiveAnnotationArg, TPrimitiveAnnotationArgs, TPrimitiveAnnotationValue, TPrimitiveBaseConfig, TPrimitiveConfig, TPrimitiveTypeArray, TPrimitiveTypeComplex, TPrimitiveTypeDef, TPrimitiveTypeFinal, TPrimitiveTypeFinalOptional, TPrimitiveTypeObject, TQueryCursorContext, TQueryLogicalOperator, TQueryOperator, TQueryScope, TSemanticToken };
|
package/dist/index.mjs
CHANGED
|
@@ -3,9 +3,9 @@ import { access, readFile, readdir, realpath } from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
5
|
import { rolldown } from "rolldown";
|
|
6
|
-
import { Node, printTree } from "@prostojs/parser";
|
|
7
6
|
import path$1 from "path";
|
|
8
7
|
import { URL } from "url";
|
|
8
|
+
import { Node, printTree } from "@prostojs/parser";
|
|
9
9
|
import { defu } from "defu";
|
|
10
10
|
import { mkdir, writeFile } from "fs/promises";
|
|
11
11
|
import { glob } from "glob";
|
|
@@ -1072,6 +1072,161 @@ function defineConfig(config) {
|
|
|
1072
1072
|
return config;
|
|
1073
1073
|
}
|
|
1074
1074
|
|
|
1075
|
+
//#endregion
|
|
1076
|
+
//#region packages/core/src/resolve-bare.ts
|
|
1077
|
+
function isBareSpecifier(specifier) {
|
|
1078
|
+
return specifier[0] !== "." && specifier[0] !== "/";
|
|
1079
|
+
}
|
|
1080
|
+
function isBareId(id) {
|
|
1081
|
+
return id.startsWith("bare:");
|
|
1082
|
+
}
|
|
1083
|
+
function parseBareSpecifier(specifier) {
|
|
1084
|
+
if (specifier.startsWith("@")) {
|
|
1085
|
+
const firstSlash$1 = specifier.indexOf("/");
|
|
1086
|
+
if (firstSlash$1 === -1) return {
|
|
1087
|
+
packageName: specifier,
|
|
1088
|
+
subpath: "."
|
|
1089
|
+
};
|
|
1090
|
+
const secondSlash = specifier.indexOf("/", firstSlash$1 + 1);
|
|
1091
|
+
if (secondSlash === -1) return {
|
|
1092
|
+
packageName: specifier,
|
|
1093
|
+
subpath: "."
|
|
1094
|
+
};
|
|
1095
|
+
return {
|
|
1096
|
+
packageName: specifier.slice(0, secondSlash),
|
|
1097
|
+
subpath: `./${specifier.slice(secondSlash + 1)}`
|
|
1098
|
+
};
|
|
1099
|
+
}
|
|
1100
|
+
const firstSlash = specifier.indexOf("/");
|
|
1101
|
+
if (firstSlash === -1) return {
|
|
1102
|
+
packageName: specifier,
|
|
1103
|
+
subpath: "."
|
|
1104
|
+
};
|
|
1105
|
+
return {
|
|
1106
|
+
packageName: specifier.slice(0, firstSlash),
|
|
1107
|
+
subpath: `./${specifier.slice(firstSlash + 1)}`
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
function resolvePackageExports(exports, subpath) {
|
|
1111
|
+
if (!exports || typeof exports !== "object") return undefined;
|
|
1112
|
+
const exportsMap = exports;
|
|
1113
|
+
const subpathWithExt = subpath === "." ? "." : `${subpath}.as`;
|
|
1114
|
+
const entry = exportsMap[subpathWithExt];
|
|
1115
|
+
if (entry) return resolveExportEntry(entry);
|
|
1116
|
+
for (const [pattern, value] of Object.entries(exportsMap)) {
|
|
1117
|
+
if (!pattern.includes("*")) continue;
|
|
1118
|
+
const match = matchSubpathPattern(pattern, subpathWithExt);
|
|
1119
|
+
if (match !== undefined) {
|
|
1120
|
+
const resolved = resolveExportEntry(value);
|
|
1121
|
+
if (resolved) return resolved.replaceAll("*", match);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
return undefined;
|
|
1125
|
+
}
|
|
1126
|
+
/**
|
|
1127
|
+
* Resolve a single export entry, checking for `atscript` condition.
|
|
1128
|
+
*/ function resolveExportEntry(entry) {
|
|
1129
|
+
if (typeof entry === "string") return entry;
|
|
1130
|
+
if (entry && typeof entry === "object") {
|
|
1131
|
+
const obj = entry;
|
|
1132
|
+
if (typeof obj["atscript"] === "string") return obj["atscript"];
|
|
1133
|
+
if (typeof obj["default"] === "string") return obj["default"];
|
|
1134
|
+
}
|
|
1135
|
+
return undefined;
|
|
1136
|
+
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Match a subpath against a pattern with a single `*` wildcard.
|
|
1139
|
+
* Returns the matched wildcard portion, or undefined if no match.
|
|
1140
|
+
*/ function matchSubpathPattern(pattern, subpath) {
|
|
1141
|
+
const starIdx = pattern.indexOf("*");
|
|
1142
|
+
if (starIdx === -1) return undefined;
|
|
1143
|
+
const prefix = pattern.slice(0, starIdx);
|
|
1144
|
+
const suffix = pattern.slice(starIdx + 1);
|
|
1145
|
+
if (subpath.startsWith(prefix) && subpath.endsWith(suffix) && subpath.length >= prefix.length + suffix.length) return subpath.slice(prefix.length, subpath.length - suffix.length);
|
|
1146
|
+
return undefined;
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* Check if a file exists.
|
|
1150
|
+
*/ async function fileExists(filePath) {
|
|
1151
|
+
try {
|
|
1152
|
+
await access(filePath);
|
|
1153
|
+
return true;
|
|
1154
|
+
} catch {
|
|
1155
|
+
return false;
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
const resolveCache = new Map();
|
|
1159
|
+
function clearResolveBareCache() {
|
|
1160
|
+
resolveCache.clear();
|
|
1161
|
+
}
|
|
1162
|
+
async function resolveBareSpecifier(specifier, fromDir) {
|
|
1163
|
+
const cacheKey = `${fromDir}\0${specifier}`;
|
|
1164
|
+
if (resolveCache.has(cacheKey)) return resolveCache.get(cacheKey);
|
|
1165
|
+
const result = await _resolveBareSpecifier(specifier, fromDir);
|
|
1166
|
+
resolveCache.set(cacheKey, result);
|
|
1167
|
+
return result;
|
|
1168
|
+
}
|
|
1169
|
+
async function _resolveBareSpecifier(specifier, fromDir) {
|
|
1170
|
+
const { packageName, subpath } = parseBareSpecifier(specifier);
|
|
1171
|
+
let dir = fromDir;
|
|
1172
|
+
const root$1 = path.parse(dir).root;
|
|
1173
|
+
while (true) {
|
|
1174
|
+
const pkgDir = path.join(dir, "node_modules", packageName);
|
|
1175
|
+
const pkgJsonPath = path.join(pkgDir, "package.json");
|
|
1176
|
+
if (await fileExists(pkgJsonPath)) {
|
|
1177
|
+
try {
|
|
1178
|
+
const pkgJson = JSON.parse(await readFile(pkgJsonPath, "utf8"));
|
|
1179
|
+
if (pkgJson.exports) {
|
|
1180
|
+
const resolved = resolvePackageExports(pkgJson.exports, subpath);
|
|
1181
|
+
if (resolved) {
|
|
1182
|
+
const fullPath = path.resolve(pkgDir, resolved);
|
|
1183
|
+
if (await fileExists(fullPath)) return resolveRealPath(fullPath);
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
} catch {}
|
|
1187
|
+
const directPath = subpath === "." ? path.join(pkgDir, "index.as") : path.join(pkgDir, `${subpath.slice(2)}.as`);
|
|
1188
|
+
if (await fileExists(directPath)) return resolveRealPath(directPath);
|
|
1189
|
+
}
|
|
1190
|
+
const parentDir = path.dirname(dir);
|
|
1191
|
+
if (parentDir === dir || dir === root$1) break;
|
|
1192
|
+
dir = parentDir;
|
|
1193
|
+
}
|
|
1194
|
+
return undefined;
|
|
1195
|
+
}
|
|
1196
|
+
/**
|
|
1197
|
+
* Resolve symlinks to get the canonical path (important for pnpm).
|
|
1198
|
+
*/ async function resolveRealPath(filePath) {
|
|
1199
|
+
try {
|
|
1200
|
+
return await realpath(filePath);
|
|
1201
|
+
} catch {
|
|
1202
|
+
return filePath;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
//#endregion
|
|
1207
|
+
//#region packages/core/src/parser/utils.ts
|
|
1208
|
+
function resolveAtscriptFromPath(from, id) {
|
|
1209
|
+
if (isBareSpecifier(from)) return `bare:${from}.as`;
|
|
1210
|
+
return `file://${path$1.join(fileUriToPath(id).split("/").slice(0, -1).join("/"), from)}.as`;
|
|
1211
|
+
}
|
|
1212
|
+
function fileUriToPath(id) {
|
|
1213
|
+
if (!id.startsWith("file://")) return id;
|
|
1214
|
+
const raw = id.slice(7);
|
|
1215
|
+
try {
|
|
1216
|
+
return decodeURIComponent(raw);
|
|
1217
|
+
} catch {
|
|
1218
|
+
return raw;
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
function getRelPath(fromUri, toUri) {
|
|
1222
|
+
const fromPath = new URL(fromUri).pathname;
|
|
1223
|
+
const toPath = new URL(toUri).pathname;
|
|
1224
|
+
const relPath = path$1.relative(path$1.dirname(fromPath), toPath);
|
|
1225
|
+
const { dir, name } = path$1.parse(relPath);
|
|
1226
|
+
const prefix = dir.startsWith("..") ? "" : "./";
|
|
1227
|
+
return `${prefix}${dir ? `${dir}/` : ""}${name}`;
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1075
1230
|
//#endregion
|
|
1076
1231
|
//#region packages/core/src/config/load-config.ts
|
|
1077
1232
|
async function bundleTsConfig(configFile, forceFormat) {
|
|
@@ -1081,6 +1236,7 @@ async function bundleTsConfig(configFile, forceFormat) {
|
|
|
1081
1236
|
const bundle = await rolldown({
|
|
1082
1237
|
input: configFile,
|
|
1083
1238
|
platform: "node",
|
|
1239
|
+
tsconfig: false,
|
|
1084
1240
|
resolve: { mainFields: ["main"] },
|
|
1085
1241
|
transform: { define: {
|
|
1086
1242
|
"__dirname": dirnameVarName,
|
|
@@ -1142,8 +1298,7 @@ async function resolveConfigFile(docUri, _root) {
|
|
|
1142
1298
|
return undefined;
|
|
1143
1299
|
}
|
|
1144
1300
|
async function findConfigFileName(d) {
|
|
1145
|
-
const
|
|
1146
|
-
const filesInWorkingDirectory = new Set(await readdir(decodeURIComponent(p)));
|
|
1301
|
+
const filesInWorkingDirectory = new Set(await readdir(fileUriToPath(d)));
|
|
1147
1302
|
for (const extension of SUPPORTED_CONFIG_FORMATS) {
|
|
1148
1303
|
const fileName = `${DEFAULT_CONFIG_BASE}${extension}`;
|
|
1149
1304
|
if (filesInWorkingDirectory.has(fileName)) return fileName;
|
|
@@ -2872,152 +3027,6 @@ var TSeverity = /*#__PURE__*/ function(TSeverity$1) {
|
|
|
2872
3027
|
return TSeverity$1;
|
|
2873
3028
|
}({});
|
|
2874
3029
|
|
|
2875
|
-
//#endregion
|
|
2876
|
-
//#region packages/core/src/resolve-bare.ts
|
|
2877
|
-
function isBareSpecifier(specifier) {
|
|
2878
|
-
return specifier[0] !== "." && specifier[0] !== "/";
|
|
2879
|
-
}
|
|
2880
|
-
function isBareId(id) {
|
|
2881
|
-
return id.startsWith("bare:");
|
|
2882
|
-
}
|
|
2883
|
-
function parseBareSpecifier(specifier) {
|
|
2884
|
-
if (specifier.startsWith("@")) {
|
|
2885
|
-
const firstSlash$1 = specifier.indexOf("/");
|
|
2886
|
-
if (firstSlash$1 === -1) return {
|
|
2887
|
-
packageName: specifier,
|
|
2888
|
-
subpath: "."
|
|
2889
|
-
};
|
|
2890
|
-
const secondSlash = specifier.indexOf("/", firstSlash$1 + 1);
|
|
2891
|
-
if (secondSlash === -1) return {
|
|
2892
|
-
packageName: specifier,
|
|
2893
|
-
subpath: "."
|
|
2894
|
-
};
|
|
2895
|
-
return {
|
|
2896
|
-
packageName: specifier.slice(0, secondSlash),
|
|
2897
|
-
subpath: `./${specifier.slice(secondSlash + 1)}`
|
|
2898
|
-
};
|
|
2899
|
-
}
|
|
2900
|
-
const firstSlash = specifier.indexOf("/");
|
|
2901
|
-
if (firstSlash === -1) return {
|
|
2902
|
-
packageName: specifier,
|
|
2903
|
-
subpath: "."
|
|
2904
|
-
};
|
|
2905
|
-
return {
|
|
2906
|
-
packageName: specifier.slice(0, firstSlash),
|
|
2907
|
-
subpath: `./${specifier.slice(firstSlash + 1)}`
|
|
2908
|
-
};
|
|
2909
|
-
}
|
|
2910
|
-
function resolvePackageExports(exports, subpath) {
|
|
2911
|
-
if (!exports || typeof exports !== "object") return undefined;
|
|
2912
|
-
const exportsMap = exports;
|
|
2913
|
-
const subpathWithExt = subpath === "." ? "." : `${subpath}.as`;
|
|
2914
|
-
const entry = exportsMap[subpathWithExt];
|
|
2915
|
-
if (entry) return resolveExportEntry(entry);
|
|
2916
|
-
for (const [pattern, value] of Object.entries(exportsMap)) {
|
|
2917
|
-
if (!pattern.includes("*")) continue;
|
|
2918
|
-
const match = matchSubpathPattern(pattern, subpathWithExt);
|
|
2919
|
-
if (match !== undefined) {
|
|
2920
|
-
const resolved = resolveExportEntry(value);
|
|
2921
|
-
if (resolved) return resolved.replaceAll("*", match);
|
|
2922
|
-
}
|
|
2923
|
-
}
|
|
2924
|
-
return undefined;
|
|
2925
|
-
}
|
|
2926
|
-
/**
|
|
2927
|
-
* Resolve a single export entry, checking for `atscript` condition.
|
|
2928
|
-
*/ function resolveExportEntry(entry) {
|
|
2929
|
-
if (typeof entry === "string") return entry;
|
|
2930
|
-
if (entry && typeof entry === "object") {
|
|
2931
|
-
const obj = entry;
|
|
2932
|
-
if (typeof obj["atscript"] === "string") return obj["atscript"];
|
|
2933
|
-
if (typeof obj["default"] === "string") return obj["default"];
|
|
2934
|
-
}
|
|
2935
|
-
return undefined;
|
|
2936
|
-
}
|
|
2937
|
-
/**
|
|
2938
|
-
* Match a subpath against a pattern with a single `*` wildcard.
|
|
2939
|
-
* Returns the matched wildcard portion, or undefined if no match.
|
|
2940
|
-
*/ function matchSubpathPattern(pattern, subpath) {
|
|
2941
|
-
const starIdx = pattern.indexOf("*");
|
|
2942
|
-
if (starIdx === -1) return undefined;
|
|
2943
|
-
const prefix = pattern.slice(0, starIdx);
|
|
2944
|
-
const suffix = pattern.slice(starIdx + 1);
|
|
2945
|
-
if (subpath.startsWith(prefix) && subpath.endsWith(suffix) && subpath.length >= prefix.length + suffix.length) return subpath.slice(prefix.length, subpath.length - suffix.length);
|
|
2946
|
-
return undefined;
|
|
2947
|
-
}
|
|
2948
|
-
/**
|
|
2949
|
-
* Check if a file exists.
|
|
2950
|
-
*/ async function fileExists(filePath) {
|
|
2951
|
-
try {
|
|
2952
|
-
await access(filePath);
|
|
2953
|
-
return true;
|
|
2954
|
-
} catch {
|
|
2955
|
-
return false;
|
|
2956
|
-
}
|
|
2957
|
-
}
|
|
2958
|
-
const resolveCache = new Map();
|
|
2959
|
-
function clearResolveBareCache() {
|
|
2960
|
-
resolveCache.clear();
|
|
2961
|
-
}
|
|
2962
|
-
async function resolveBareSpecifier(specifier, fromDir) {
|
|
2963
|
-
const cacheKey = `${fromDir}\0${specifier}`;
|
|
2964
|
-
if (resolveCache.has(cacheKey)) return resolveCache.get(cacheKey);
|
|
2965
|
-
const result = await _resolveBareSpecifier(specifier, fromDir);
|
|
2966
|
-
resolveCache.set(cacheKey, result);
|
|
2967
|
-
return result;
|
|
2968
|
-
}
|
|
2969
|
-
async function _resolveBareSpecifier(specifier, fromDir) {
|
|
2970
|
-
const { packageName, subpath } = parseBareSpecifier(specifier);
|
|
2971
|
-
let dir = fromDir;
|
|
2972
|
-
const root$1 = path.parse(dir).root;
|
|
2973
|
-
while (true) {
|
|
2974
|
-
const pkgDir = path.join(dir, "node_modules", packageName);
|
|
2975
|
-
const pkgJsonPath = path.join(pkgDir, "package.json");
|
|
2976
|
-
if (await fileExists(pkgJsonPath)) {
|
|
2977
|
-
try {
|
|
2978
|
-
const pkgJson = JSON.parse(await readFile(pkgJsonPath, "utf8"));
|
|
2979
|
-
if (pkgJson.exports) {
|
|
2980
|
-
const resolved = resolvePackageExports(pkgJson.exports, subpath);
|
|
2981
|
-
if (resolved) {
|
|
2982
|
-
const fullPath = path.resolve(pkgDir, resolved);
|
|
2983
|
-
if (await fileExists(fullPath)) return resolveRealPath(fullPath);
|
|
2984
|
-
}
|
|
2985
|
-
}
|
|
2986
|
-
} catch {}
|
|
2987
|
-
const directPath = subpath === "." ? path.join(pkgDir, "index.as") : path.join(pkgDir, `${subpath.slice(2)}.as`);
|
|
2988
|
-
if (await fileExists(directPath)) return resolveRealPath(directPath);
|
|
2989
|
-
}
|
|
2990
|
-
const parentDir = path.dirname(dir);
|
|
2991
|
-
if (parentDir === dir || dir === root$1) break;
|
|
2992
|
-
dir = parentDir;
|
|
2993
|
-
}
|
|
2994
|
-
return undefined;
|
|
2995
|
-
}
|
|
2996
|
-
/**
|
|
2997
|
-
* Resolve symlinks to get the canonical path (important for pnpm).
|
|
2998
|
-
*/ async function resolveRealPath(filePath) {
|
|
2999
|
-
try {
|
|
3000
|
-
return await realpath(filePath);
|
|
3001
|
-
} catch {
|
|
3002
|
-
return filePath;
|
|
3003
|
-
}
|
|
3004
|
-
}
|
|
3005
|
-
|
|
3006
|
-
//#endregion
|
|
3007
|
-
//#region packages/core/src/parser/utils.ts
|
|
3008
|
-
function resolveAtscriptFromPath(from, id) {
|
|
3009
|
-
if (isBareSpecifier(from)) return `bare:${from}.as`;
|
|
3010
|
-
return `file://${path$1.join(id.slice(7).split("/").slice(0, -1).join("/"), from)}.as`;
|
|
3011
|
-
}
|
|
3012
|
-
function getRelPath(fromUri, toUri) {
|
|
3013
|
-
const fromPath = new URL(fromUri).pathname;
|
|
3014
|
-
const toPath = new URL(toUri).pathname;
|
|
3015
|
-
const relPath = path$1.relative(path$1.dirname(fromPath), toPath);
|
|
3016
|
-
const { dir, name } = path$1.parse(relPath);
|
|
3017
|
-
const prefix = dir.startsWith("..") ? "" : "./";
|
|
3018
|
-
return `${prefix}${dir ? `${dir}/` : ""}${name}`;
|
|
3019
|
-
}
|
|
3020
|
-
|
|
3021
3030
|
//#endregion
|
|
3022
3031
|
//#region packages/core/src/token-index/blocks-index.ts
|
|
3023
3032
|
function _define_property$5(obj, key, value) {
|
|
@@ -4812,7 +4821,7 @@ var PluginManager = class {
|
|
|
4812
4821
|
return newId;
|
|
4813
4822
|
}
|
|
4814
4823
|
async load(id) {
|
|
4815
|
-
const filePath =
|
|
4824
|
+
const filePath = fileUriToPath(id);
|
|
4816
4825
|
for (const plugin of this.plugins) if (plugin.load) {
|
|
4817
4826
|
const content = await plugin.load(id);
|
|
4818
4827
|
if (content) return content;
|
|
@@ -4823,7 +4832,7 @@ var PluginManager = class {
|
|
|
4823
4832
|
for (const plugin of this.plugins) if (plugin.onDocument) await plugin.onDocument(doc);
|
|
4824
4833
|
}
|
|
4825
4834
|
async render(doc, format) {
|
|
4826
|
-
const source =
|
|
4835
|
+
const source = fileUriToPath(doc.id);
|
|
4827
4836
|
const files = [];
|
|
4828
4837
|
for (const plugin of this.plugins) if (plugin.render) {
|
|
4829
4838
|
const newFiles = await plugin.render(doc, format);
|
|
@@ -5049,7 +5058,7 @@ else types.push({ type: "boolean" });
|
|
|
5049
5058
|
async checkImport(atscript, from, imports, checked) {
|
|
5050
5059
|
let forId = resolveAtscriptFromPath(from.text, atscript.id);
|
|
5051
5060
|
if (isBareId(forId)) {
|
|
5052
|
-
const fromDir = atscript.id
|
|
5061
|
+
const fromDir = fileUriToPath(atscript.id).split("/").slice(0, -1).join("/");
|
|
5053
5062
|
const resolved = await resolveBareSpecifier(from.text, fromDir);
|
|
5054
5063
|
if (!resolved) {
|
|
5055
5064
|
atscript.registerMessages([{
|
|
@@ -5454,4 +5463,4 @@ else if (isGroup(def) && def.entity !== "structure") {
|
|
|
5454
5463
|
}
|
|
5455
5464
|
|
|
5456
5465
|
//#endregion
|
|
5457
|
-
export { $n, AnnotationSpec, AtscriptDoc, AtscriptRepo, BuildRepo, DEFAULT_FORMAT, PluginManager, SemanticAnnotateNode, SemanticArrayNode, SemanticConstNode, SemanticGroup, SemanticImportNode, SemanticInterfaceNode, SemanticNode, SemanticPrimitiveNode, SemanticPropNode, SemanticQueryComparisonNode, SemanticQueryFieldRefNode, SemanticQueryLogicalNode, SemanticQueryNode, SemanticQueryValueListNode, SemanticQueryValueNode, SemanticRefNode, SemanticStructureNode, SemanticTupleNode, SemanticTypeNode, Token, analyzeQueryCursorContext, build, clearResolveBareCache, createAtscriptPlugin, defineConfig, flattenInterfaceNode, getFieldsForType, getQueryCompletionScope, getQueryScope, getRelPath, hasNavPropAnnotation, isAnnotate, isAnnotationSpec, isArray, isBareId, isBareSpecifier, isConst, isGroup, isImport, isInterface, isPhantomNode, isPrimitive, isProp, isQueryComparison, isQueryFieldRef, isQueryLogical, isRef, isStructure, isTuple, isType, loadConfig, loadTsConfig, parseBareSpecifier, resolveAnnotation, resolveAtscriptFromPath, resolveBareSpecifier, resolveConfigFile, resolveQueryFieldRef };
|
|
5466
|
+
export { $n, AnnotationSpec, AtscriptDoc, AtscriptRepo, BuildRepo, DEFAULT_FORMAT, PluginManager, SemanticAnnotateNode, SemanticArrayNode, SemanticConstNode, SemanticGroup, SemanticImportNode, SemanticInterfaceNode, SemanticNode, SemanticPrimitiveNode, SemanticPropNode, SemanticQueryComparisonNode, SemanticQueryFieldRefNode, SemanticQueryLogicalNode, SemanticQueryNode, SemanticQueryValueListNode, SemanticQueryValueNode, SemanticRefNode, SemanticStructureNode, SemanticTupleNode, SemanticTypeNode, Token, analyzeQueryCursorContext, build, clearResolveBareCache, createAtscriptPlugin, defineConfig, fileUriToPath, flattenInterfaceNode, getFieldsForType, getQueryCompletionScope, getQueryScope, getRelPath, hasNavPropAnnotation, isAnnotate, isAnnotationSpec, isArray, isBareId, isBareSpecifier, isConst, isGroup, isImport, isInterface, isPhantomNode, isPrimitive, isProp, isQueryComparison, isQueryFieldRef, isQueryLogical, isRef, isStructure, isTuple, isType, loadConfig, loadTsConfig, parseBareSpecifier, resolveAnnotation, resolveAtscriptFromPath, resolveBareSpecifier, resolveConfigFile, resolveQueryFieldRef };
|