@defold-typescript/transpiler 0.36.0 → 0.37.0
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.d.ts +1 -1
- package/dist/index.js +12 -0
- package/dist/output-paths.d.ts +1 -0
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/output-paths.ts +24 -0
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type { ExtensionDependency, LibraryIncludedEntries, LibrarySceneDocument,
|
|
|
13
13
|
export { archiveWrapperOf, isContainedResourcePath, LIBRARY_DEPENDENCY_ROOT, libraryIncludedEntries, readGameProjectDependencies, readLibrarySceneDocuments, } from "./library-dependencies";
|
|
14
14
|
export { findMainEntryFactoryImports } from "./main-entry-factory-imports";
|
|
15
15
|
export type { BuildConfig, ScriptKind, SourceOutputKind } from "./output-paths";
|
|
16
|
-
export { computeOutputRel, DEFAULT_INCLUDE, parseBuildConfig, requirePathForRel, SCRIPT_SUFFIX_BY_KIND, stripIncludeBase, } from "./output-paths";
|
|
16
|
+
export { computeOutputRel, DEFAULT_INCLUDE, parseBuildConfig, projectRelativeBase, requirePathForRel, SCRIPT_SUFFIX_BY_KIND, stripIncludeBase, } from "./output-paths";
|
|
17
17
|
export { getProgramDiagnostics } from "./program-diagnostics";
|
|
18
18
|
export { isDefignoredPath, SCAFFOLDED_DEFIGNORE_LINES } from "./project-resources";
|
|
19
19
|
export { rewriteEmittedRequires } from "./require-rewrite";
|
package/dist/index.js
CHANGED
|
@@ -1993,6 +1993,17 @@ function stripIncludeBase(pattern) {
|
|
|
1993
1993
|
const lastSlash = upToWildcard.lastIndexOf("/");
|
|
1994
1994
|
return lastSlash === -1 ? "" : upToWildcard.slice(0, lastSlash + 1);
|
|
1995
1995
|
}
|
|
1996
|
+
var ABSOLUTE_SPELLING_RE = /^(\/|\\\\|[A-Za-z]:[\\/])/;
|
|
1997
|
+
function projectRelativeBase(pattern) {
|
|
1998
|
+
if (ABSOLUTE_SPELLING_RE.test(pattern)) {
|
|
1999
|
+
return;
|
|
2000
|
+
}
|
|
2001
|
+
const base = path.posix.normalize(stripIncludeBase(pattern.split("\\").join("/")));
|
|
2002
|
+
if (base === ".." || base.startsWith("../")) {
|
|
2003
|
+
return;
|
|
2004
|
+
}
|
|
2005
|
+
return base === "." || base === "./" ? "" : base;
|
|
2006
|
+
}
|
|
1996
2007
|
function relUnderOutDir(rel, config) {
|
|
1997
2008
|
const { outDir, include } = config;
|
|
1998
2009
|
if (outDir === undefined || outDir === "" || outDir === ".") {
|
|
@@ -3901,6 +3912,7 @@ export {
|
|
|
3901
3912
|
listProjectResourcePaths,
|
|
3902
3913
|
parseBuildConfig,
|
|
3903
3914
|
parseSceneTextFormat,
|
|
3915
|
+
projectRelativeBase,
|
|
3904
3916
|
readGameProjectDependencies,
|
|
3905
3917
|
readGameProjectSetting,
|
|
3906
3918
|
readLibrarySceneDocuments,
|
package/dist/output-paths.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const DEFAULT_INCLUDE: string[];
|
|
|
8
8
|
export declare const SCRIPT_SUFFIX_BY_KIND: Record<ScriptKind, string>;
|
|
9
9
|
export declare function parseBuildConfig(raw: string): BuildConfig;
|
|
10
10
|
export declare function stripIncludeBase(pattern: string): string;
|
|
11
|
+
export declare function projectRelativeBase(pattern: string): string | undefined;
|
|
11
12
|
/**
|
|
12
13
|
* The `require` path Lua reaches a rel by, mirroring the segment math TSTL
|
|
13
14
|
* applies when it emits one: the extension comes off the last segment, then
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defold-typescript/transpiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "TypeScript-to-Lua build pipeline tuned for Defold's runtime.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"test": "bun test"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@defold-typescript/types": "0.
|
|
38
|
+
"@defold-typescript/types": "0.37.0",
|
|
39
39
|
"@typescript-to-lua/language-extensions": "1.19.0",
|
|
40
40
|
"typescript-to-lua": "^1.36.0"
|
|
41
41
|
}
|
package/src/index.ts
CHANGED
package/src/output-paths.ts
CHANGED
|
@@ -46,6 +46,30 @@ export function stripIncludeBase(pattern: string): string {
|
|
|
46
46
|
return lastSlash === -1 ? "" : upToWildcard.slice(0, lastSlash + 1);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
// A root is a folder inside the project a tool can safely speak for, so a
|
|
50
|
+
// pattern that resolves to the project root, escapes `cwd`, or is absolute in
|
|
51
|
+
// any spelling yields nothing. Escape is the normalized `..` *segment*, not a
|
|
52
|
+
// two-period prefix: `..local` is an ordinary folder name. Absoluteness is
|
|
53
|
+
// decided by string shape, never by `path.isAbsolute`, which answers for the
|
|
54
|
+
// host OS and would wave a Windows drive or UNC path through on a POSIX runner.
|
|
55
|
+
const ABSOLUTE_SPELLING_RE = /^(\/|\\\\|[A-Za-z]:[\\/])/;
|
|
56
|
+
|
|
57
|
+
// The folder an include pattern speaks for, as a project-relative posix base
|
|
58
|
+
// (`""` for the project root itself), or `undefined` when the pattern reaches
|
|
59
|
+
// outside the project. The scaffold-rule roots, the starter target and the
|
|
60
|
+
// debug launch derivation all answer "which project folder does this pattern
|
|
61
|
+
// speak for" here, so the three cannot drift.
|
|
62
|
+
export function projectRelativeBase(pattern: string): string | undefined {
|
|
63
|
+
if (ABSOLUTE_SPELLING_RE.test(pattern)) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
const base = path.posix.normalize(stripIncludeBase(pattern.split("\\").join("/")));
|
|
67
|
+
if (base === ".." || base.startsWith("../")) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return base === "." || base === "./" ? "" : base;
|
|
71
|
+
}
|
|
72
|
+
|
|
49
73
|
function relUnderOutDir(rel: string, config: BuildConfig): string {
|
|
50
74
|
const { outDir, include } = config;
|
|
51
75
|
if (outDir === undefined || outDir === "" || outDir === ".") {
|