@defold-typescript/transpiler 0.35.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.
@@ -0,0 +1,57 @@
1
+ import * as ts from "typescript";
2
+ /**
3
+ * The exports-table field a companion exposes its private members on. Reserving
4
+ * one name keeps the field collision-safe without mangling every internal name,
5
+ * which is why a source exporting it is rejected rather than shadowed.
6
+ */
7
+ export declare const COMPANION_INTERNAL_FIELD = "____closure";
8
+ export type ClosureViolationKind = "shared-mutable" | "initialization-order" | "reserved-internal-name";
9
+ export interface ClosureSite {
10
+ /** What this position is — the phrase the message uses for it. */
11
+ readonly role: string;
12
+ /** 1-based. */
13
+ readonly line: number;
14
+ /** 1-based. */
15
+ readonly column: number;
16
+ }
17
+ export interface ClosureViolation {
18
+ readonly kind: ClosureViolationKind;
19
+ /** The declaration the split cannot preserve. */
20
+ readonly member: string;
21
+ readonly sites: readonly ClosureSite[];
22
+ readonly message: string;
23
+ }
24
+ export interface CompanionClosure {
25
+ /** Top-level declarations that would move into the companion, in source order. */
26
+ readonly members: readonly string[];
27
+ /** The runtime value exports that open the companion, in source order. */
28
+ readonly exports: readonly string[];
29
+ /** Members outside `exports` the script still references, in source order. */
30
+ readonly internals: readonly string[];
31
+ /**
32
+ * The top-level statements carrying those members, in source order. A
33
+ * statement, not a name, is what the emit actually moves: one `const a = 1, b
34
+ * = 2;` is two members and one unit of code.
35
+ */
36
+ readonly statements: readonly ts.Statement[];
37
+ /**
38
+ * Import bindings the closure reaches, in source order. An import is copyable
39
+ * rather than movable — its statement never appears in `statements` — so the
40
+ * companion takes its own `require` of the same module instead.
41
+ */
42
+ readonly importBindings: readonly string[];
43
+ /** Shapes a split cannot preserve. Empty means the source is splittable. */
44
+ readonly violations: readonly ClosureViolation[];
45
+ }
46
+ /**
47
+ * Which of a script-kind source's top-level declarations would move into a
48
+ * companion module, and the shapes a split cannot preserve.
49
+ *
50
+ * The companion holds the transitive closure of top-level declarations
51
+ * reachable from the source's runtime value exports; everything else stays in
52
+ * the script and runs there once. Two shapes break that split — a binding
53
+ * reassigned on one side and read on the other, which a Lua local cannot carry,
54
+ * and effectful top-level work the split would reorder — and both are reported
55
+ * against the source rather than emitted.
56
+ */
57
+ export declare function computeCompanionClosure(sourceFile: ts.SourceFile, checker: ts.TypeChecker): CompanionClosure;
@@ -0,0 +1,21 @@
1
+ import { type Plugin } from "typescript-to-lua";
2
+ export interface CompanionEmitter {
3
+ readonly plugin: Plugin;
4
+ /**
5
+ * Companion Lua by source file name, for the sources that produced one. Read
6
+ * after a transpile; a source absent from it emits a single chunk.
7
+ */
8
+ readonly companions: ReadonlyMap<string, string>;
9
+ }
10
+ /**
11
+ * Splits a script-kind source that exports runtime values into two chunks: a
12
+ * companion module holding the dependency closure of those exports, and the
13
+ * script, which requires it rather than redeclaring it. One definition then
14
+ * serves the script's own hooks and every importer, which is what makes a
15
+ * mutable export the same table on both sides.
16
+ *
17
+ * A factory rather than a shared constant: the captured chunks belong to one
18
+ * transpile, and a module-level plugin would leak them between the editor
19
+ * session's rebuilds.
20
+ */
21
+ export declare function createCompanionEmitPlugin(): CompanionEmitter;
@@ -0,0 +1,7 @@
1
+ export declare const LUALIB_REQUIRE_NAME = "lualib_bundle";
2
+ /**
3
+ * The distinct string-literal module paths an emitted Lua chunk requires, in
4
+ * source order. The two generated runtimes are skipped, as is any require whose
5
+ * argument is not a string literal — neither can name a source the build owns.
6
+ */
7
+ export declare function findEmittedRequires(lua: string): string[];
package/dist/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
+ export type { ClosureSite, ClosureViolation, ClosureViolationKind, CompanionClosure, } from "./companion-closure";
2
+ export { COMPANION_INTERNAL_FIELD, computeCompanionClosure } from "./companion-closure";
1
3
  export type { ComponentAnimationIndex } from "./component-animation-index";
2
4
  export { buildComponentAnimationIndex, componentIdOfSameObjectAddress, } from "./component-animation-index";
3
5
  export { buildConfigKeyIndex, readGameProjectSetting } from "./config-key-index";
6
+ export { findEmittedRequires, LUALIB_REQUIRE_NAME } from "./emitted-requires";
4
7
  export type { GuiFlipbookIndex } from "./gui-flipbook-index";
5
8
  export { buildGuiFlipbookIndex } from "./gui-flipbook-index";
6
9
  export type { GuiNodeIndex } from "./gui-node-index";
@@ -10,9 +13,10 @@ export type { ExtensionDependency, LibraryIncludedEntries, LibrarySceneDocument,
10
13
  export { archiveWrapperOf, isContainedResourcePath, LIBRARY_DEPENDENCY_ROOT, libraryIncludedEntries, readGameProjectDependencies, readLibrarySceneDocuments, } from "./library-dependencies";
11
14
  export { findMainEntryFactoryImports } from "./main-entry-factory-imports";
12
15
  export type { BuildConfig, ScriptKind, SourceOutputKind } from "./output-paths";
13
- export { computeOutputRel, DEFAULT_INCLUDE, parseBuildConfig, SCRIPT_SUFFIX_BY_KIND, stripIncludeBase, } from "./output-paths";
16
+ export { computeOutputRel, DEFAULT_INCLUDE, parseBuildConfig, projectRelativeBase, requirePathForRel, SCRIPT_SUFFIX_BY_KIND, stripIncludeBase, } from "./output-paths";
14
17
  export { getProgramDiagnostics } from "./program-diagnostics";
15
18
  export { isDefignoredPath, SCAFFOLDED_DEFIGNORE_LINES } from "./project-resources";
19
+ export { rewriteEmittedRequires } from "./require-rewrite";
16
20
  export { buildSceneAddressDeclaration } from "./scene-address-declaration";
17
21
  export type { SceneCollectionRoles, SceneCollectionRolesInput } from "./scene-collection-roles";
18
22
  export { buildSceneCollectionRoles } from "./scene-collection-roles";
@@ -28,6 +32,7 @@ export type { SceneMessage } from "./scene-text-format";
28
32
  export { parseSceneTextFormat, SceneTextFormatError } from "./scene-text-format";
29
33
  export type { TranspileSession } from "./session";
30
34
  export { createTranspileSession } from "./session";
35
+ export { TIMERS_REQUIRE_NAME } from "./timers-runtime";
31
36
  export type { TranspileDiagnostic, TranspileProjectInput, TranspileProjectResult, TranspileResult, } from "./transpile";
32
37
  export { transpile, transpileProject } from "./transpile";
33
38
  export type { ClassifiedSlot } from "./url-address-slots";