@trioforge/crucible 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/client/package.json +4 -0
- package/emit/package.json +4 -0
- package/out/all.d.ts +7 -0
- package/out/all.luau +2 -0
- package/out/attribute.d.ts +7 -0
- package/out/attribute.luau +7 -0
- package/out/client/index.d.ts +3 -0
- package/out/client/init.luau +20 -0
- package/out/crucible-behaviour.d.ts +16 -0
- package/out/crucible-behaviour.luau +78 -0
- package/out/crucible-object.d.ts +10 -0
- package/out/crucible-object.luau +69 -0
- package/out/emit/index.d.ts +41 -0
- package/out/emit/init.luau +85 -0
- package/out/index.d.ts +12 -0
- package/out/init.luau +11 -0
- package/out/inject.d.ts +1 -0
- package/out/inject.luau +7 -0
- package/out/internal/binding.d.ts +1 -0
- package/out/internal/binding.luau +610 -0
- package/out/internal/boot.d.ts +1 -0
- package/out/internal/boot.luau +463 -0
- package/out/internal/construction-claim.d.ts +1 -0
- package/out/internal/construction-claim.luau +26 -0
- package/out/internal/dense-list.d.ts +1 -0
- package/out/internal/dense-list.luau +155 -0
- package/out/internal/diagnostics.d.ts +1 -0
- package/out/internal/diagnostics.luau +29 -0
- package/out/internal/hooks.d.ts +1 -0
- package/out/internal/hooks.luau +53 -0
- package/out/internal/implementers.d.ts +1 -0
- package/out/internal/implementers.luau +119 -0
- package/out/internal/lifecycle.d.ts +1 -0
- package/out/internal/lifecycle.luau +867 -0
- package/out/internal/log-output.d.ts +1 -0
- package/out/internal/log-output.luau +106 -0
- package/out/internal/port.d.ts +1 -0
- package/out/internal/port.luau +12 -0
- package/out/internal/registry.d.ts +1 -0
- package/out/internal/registry.luau +446 -0
- package/out/internal/roblox-port.d.ts +1 -0
- package/out/internal/roblox-port.luau +117 -0
- package/out/internal/runner.d.ts +1 -0
- package/out/internal/runner.luau +86 -0
- package/out/internal/scheduler.d.ts +1 -0
- package/out/internal/scheduler.luau +207 -0
- package/out/internal/state.d.ts +1 -0
- package/out/internal/state.luau +41 -0
- package/out/log-level.d.ts +7 -0
- package/out/log-level.luau +21 -0
- package/out/logging.d.ts +34 -0
- package/out/logging.luau +233 -0
- package/out/server/index.d.ts +2 -0
- package/out/server/init.luau +16 -0
- package/out/subsystem.d.ts +4 -0
- package/out/subsystem.luau +30 -0
- package/package.json +41 -5
- package/server/package.json +4 -0
- package/transformer/diagnostics.cjs +19 -0
- package/transformer/index.js +715 -0
- package/transformer/type-id.cjs +80 -0
- package/README.md +0 -3
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const fs = require("node:fs");
|
|
2
|
+
const path = require("node:path");
|
|
3
|
+
|
|
4
|
+
function packageOf(file) {
|
|
5
|
+
let dir = path.dirname(path.resolve(file));
|
|
6
|
+
for (;;) {
|
|
7
|
+
const manifest = path.join(dir, "package.json");
|
|
8
|
+
if (fs.existsSync(manifest)) return { dir, json: JSON.parse(fs.readFileSync(manifest, "utf8")) };
|
|
9
|
+
const parent = path.dirname(dir);
|
|
10
|
+
if (parent === dir) return undefined;
|
|
11
|
+
dir = parent;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function typesCondition(value) {
|
|
16
|
+
if (!value || typeof value !== "object") return [];
|
|
17
|
+
if (typeof value.types === "string") return [value.types];
|
|
18
|
+
return Object.values(value).flatMap(typesCondition);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function sourceRoot(options, directories = []) {
|
|
22
|
+
if (options.rootDir) return path.resolve(options.rootDir);
|
|
23
|
+
const dirs = [...directories, ...(options.rootDirs ?? [])].map((dir) => path.resolve(dir));
|
|
24
|
+
let root = dirs[0];
|
|
25
|
+
if (!root) return undefined;
|
|
26
|
+
while (
|
|
27
|
+
!dirs.every((dir) => {
|
|
28
|
+
const relative = path.relative(root, dir);
|
|
29
|
+
return !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
30
|
+
})
|
|
31
|
+
) {
|
|
32
|
+
const parent = path.dirname(root);
|
|
33
|
+
if (parent === root) return undefined;
|
|
34
|
+
root = parent;
|
|
35
|
+
}
|
|
36
|
+
return root;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function typeId(file, name, program, ts) {
|
|
40
|
+
const owner = packageOf(file);
|
|
41
|
+
if (!owner?.json.name) return undefined;
|
|
42
|
+
let root;
|
|
43
|
+
if (/\.d\.tsx?$/.test(file)) {
|
|
44
|
+
const entries = typesCondition(owner.json.exports?.["."] ?? owner.json.exports);
|
|
45
|
+
const entry =
|
|
46
|
+
entries.find((entry) => {
|
|
47
|
+
const relative = path.relative(path.dirname(path.resolve(owner.dir, entry)), file);
|
|
48
|
+
return !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
49
|
+
}) ??
|
|
50
|
+
owner.json.types ??
|
|
51
|
+
owner.json.typings ??
|
|
52
|
+
"index.d.ts";
|
|
53
|
+
root = path.dirname(path.resolve(owner.dir, entry));
|
|
54
|
+
} else {
|
|
55
|
+
const config = ts.findConfigFile(path.dirname(file), ts.sys.fileExists);
|
|
56
|
+
if (config && packageOf(config)?.dir === owner.dir) {
|
|
57
|
+
const parsed = ts.getParsedCommandLineOfConfigFile(
|
|
58
|
+
config,
|
|
59
|
+
{},
|
|
60
|
+
{ ...ts.sys, onUnRecoverableConfigFileDiagnostic() {} },
|
|
61
|
+
);
|
|
62
|
+
if (parsed)
|
|
63
|
+
root = sourceRoot(
|
|
64
|
+
parsed.options,
|
|
65
|
+
parsed.fileNames.filter((file) => !/\.d\.tsx?$/.test(file)).map((file) => path.dirname(file)),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
root ??= program.getCompilerOptions().rootDir;
|
|
69
|
+
root ??= owner.dir;
|
|
70
|
+
}
|
|
71
|
+
const modulePath = path
|
|
72
|
+
.relative(root, file)
|
|
73
|
+
.split(path.sep)
|
|
74
|
+
.join("/")
|
|
75
|
+
.replace(/(\.d)?\.tsx?$/, "");
|
|
76
|
+
if (modulePath.startsWith("../") || path.isAbsolute(modulePath)) return undefined;
|
|
77
|
+
return `${owner.json.name}/${modulePath}:${name}`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
module.exports = { packageOf, typeId, sourceRoot };
|
package/README.md
DELETED