@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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/client/package.json +4 -0
  3. package/emit/package.json +4 -0
  4. package/out/all.d.ts +7 -0
  5. package/out/all.luau +2 -0
  6. package/out/attribute.d.ts +7 -0
  7. package/out/attribute.luau +7 -0
  8. package/out/client/index.d.ts +3 -0
  9. package/out/client/init.luau +20 -0
  10. package/out/crucible-behaviour.d.ts +16 -0
  11. package/out/crucible-behaviour.luau +78 -0
  12. package/out/crucible-object.d.ts +10 -0
  13. package/out/crucible-object.luau +69 -0
  14. package/out/emit/index.d.ts +41 -0
  15. package/out/emit/init.luau +85 -0
  16. package/out/index.d.ts +12 -0
  17. package/out/init.luau +11 -0
  18. package/out/inject.d.ts +1 -0
  19. package/out/inject.luau +7 -0
  20. package/out/internal/binding.d.ts +1 -0
  21. package/out/internal/binding.luau +610 -0
  22. package/out/internal/boot.d.ts +1 -0
  23. package/out/internal/boot.luau +463 -0
  24. package/out/internal/construction-claim.d.ts +1 -0
  25. package/out/internal/construction-claim.luau +26 -0
  26. package/out/internal/dense-list.d.ts +1 -0
  27. package/out/internal/dense-list.luau +155 -0
  28. package/out/internal/diagnostics.d.ts +1 -0
  29. package/out/internal/diagnostics.luau +29 -0
  30. package/out/internal/hooks.d.ts +1 -0
  31. package/out/internal/hooks.luau +53 -0
  32. package/out/internal/implementers.d.ts +1 -0
  33. package/out/internal/implementers.luau +119 -0
  34. package/out/internal/lifecycle.d.ts +1 -0
  35. package/out/internal/lifecycle.luau +867 -0
  36. package/out/internal/log-output.d.ts +1 -0
  37. package/out/internal/log-output.luau +106 -0
  38. package/out/internal/port.d.ts +1 -0
  39. package/out/internal/port.luau +12 -0
  40. package/out/internal/registry.d.ts +1 -0
  41. package/out/internal/registry.luau +446 -0
  42. package/out/internal/roblox-port.d.ts +1 -0
  43. package/out/internal/roblox-port.luau +117 -0
  44. package/out/internal/runner.d.ts +1 -0
  45. package/out/internal/runner.luau +86 -0
  46. package/out/internal/scheduler.d.ts +1 -0
  47. package/out/internal/scheduler.luau +207 -0
  48. package/out/internal/state.d.ts +1 -0
  49. package/out/internal/state.luau +41 -0
  50. package/out/log-level.d.ts +7 -0
  51. package/out/log-level.luau +21 -0
  52. package/out/logging.d.ts +34 -0
  53. package/out/logging.luau +233 -0
  54. package/out/server/index.d.ts +2 -0
  55. package/out/server/init.luau +16 -0
  56. package/out/subsystem.d.ts +4 -0
  57. package/out/subsystem.luau +30 -0
  58. package/package.json +41 -5
  59. package/server/package.json +4 -0
  60. package/transformer/diagnostics.cjs +19 -0
  61. package/transformer/index.js +715 -0
  62. package/transformer/type-id.cjs +80 -0
  63. 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
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.