@flamework-experimental/core 2.0.0-alpha.2 → 2.0.0-alpha.4

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 (44) hide show
  1. package/README.md +41 -34
  2. package/docs/README.md +63 -0
  3. package/docs/guide/01-getting-started.md +334 -0
  4. package/docs/guide/02-modules.md +254 -0
  5. package/docs/guide/03-providers.md +423 -0
  6. package/docs/guide/04-lifecycle-events.md +423 -0
  7. package/docs/guide/05-components.md +793 -0
  8. package/docs/guide/06-networking.md +614 -0
  9. package/docs/guide/07-macros.md +332 -0
  10. package/docs/guide/08-plugins.md +203 -0
  11. package/docs/guide/09-project-structure.md +392 -0
  12. package/docs/guide/10-migrating-from-v1.md +573 -0
  13. package/docs/guide/11-scopes.md +165 -0
  14. package/docs/guide/12-testing.md +342 -0
  15. package/flamework.build +1 -1
  16. package/out/dependency.d.ts +4 -0
  17. package/out/dependency.luau +4 -0
  18. package/out/index.d.ts +5 -2
  19. package/out/init.luau +11 -2
  20. package/out/lifecycle/lifecyclePlugin.d.ts +13 -1
  21. package/out/lifecycle/lifecyclePlugin.luau +67 -7
  22. package/out/module/module.luau +126 -24
  23. package/out/module/moduleBuilder.d.ts +12 -3
  24. package/out/module/moduleBuilder.luau +23 -1
  25. package/out/module/moduleDefinition.d.ts +6 -0
  26. package/out/module/providerRegistration.d.ts +8 -0
  27. package/out/module/providerRegistration.luau +29 -0
  28. package/out/plugin/pluginDefinition.d.ts +7 -4
  29. package/out/provider.d.ts +19 -0
  30. package/out/provider.luau +8 -0
  31. package/out/reflect.luau +6 -0
  32. package/out/utility/explainUnresolved.d.ts +9 -0
  33. package/out/utility/explainUnresolved.luau +43 -0
  34. package/out/utility/getClassesInPath.d.ts +37 -3
  35. package/out/utility/getClassesInPath.luau +154 -33
  36. package/out/utility/globs.d.ts +2 -2
  37. package/out/utility/globs.luau +3 -3
  38. package/out/utility/leftOut.d.ts +35 -0
  39. package/out/utility/leftOut.luau +171 -0
  40. package/out/utility/moduleClasses.d.ts +9 -0
  41. package/out/utility/moduleClasses.luau +64 -0
  42. package/out/utility/pathRoot.d.ts +20 -1
  43. package/out/utility/pathRoot.luau +80 -4
  44. package/package.json +14 -7
@@ -56,13 +56,14 @@ local function getPathRoot()
56
56
  end
57
57
  --[[
58
58
  *
59
- * Walks a compile-time path from {@link getPathRoot}, waiting for each child in turn.
59
+ * Walks a compile-time path from {@link getPathRoot}, asking `child` for each segment in turn, and
60
+ * stops at the first segment it has no instance for.
60
61
  *
61
62
  * Under `game` the first segment names a service, and `StarterPlayer/StarterPlayerScripts` is
62
63
  * answered from the local player's `PlayerScripts`, which is where that content actually runs.
63
64
 
64
65
  ]]
65
- local function resolveRbxPath(rbxPath)
66
+ local function walkRbxPath(rbxPath, child)
66
67
  -- Copied so that a generated path literal is not consumed by this call.
67
68
  local _array = {}
68
69
  local _length = #_array
@@ -83,9 +84,83 @@ local function resolveRbxPath(rbxPath)
83
84
  end
84
85
  end
85
86
  for _, segment in path do
86
- node = node:WaitForChild(segment)
87
+ local found = child(node, segment)
88
+ if found == nil then
89
+ return {
90
+ found = node,
91
+ missing = segment,
92
+ }
93
+ end
94
+ node = found
95
+ end
96
+ return {
97
+ found = node,
98
+ }
99
+ end
100
+ --[[
101
+ *
102
+ * How long a child of a path is waited for before the wait is warned about, in seconds: when the
103
+ * engine would warn of an infinite yield, which names neither the call nor the source path.
104
+
105
+ ]]
106
+ local MISSING_CHILD_WARNING = 5
107
+ --* A child that is there now, or once a client has loaded the place and `timeout` seconds more have passed.
108
+ local function waitForChild(parent, name, timeout)
109
+ local child = parent:FindFirstChild(name)
110
+ if child ~= nil then
111
+ return child
112
+ end
113
+ -- A client receives the place's content as it loads, so its time only starts once it has loaded.
114
+ if RunService:IsClient() and not game:IsLoaded() then
115
+ game.Loaded:Wait()
87
116
  end
88
- return node
117
+ return parent:WaitForChild(name, timeout)
118
+ end
119
+ --[[
120
+ *
121
+ * Walks a compile-time path from {@link getPathRoot}, waiting for each child in turn.
122
+ *
123
+ * Under `game` the first segment names a service, and `StarterPlayer/StarterPlayerScripts` is
124
+ * answered from the local player's `PlayerScripts`, which is where that content actually runs.
125
+ *
126
+ * A child that is not there within five seconds (on a client, once the place has loaded) is warned
127
+ * about, naming `caller` -- the call that gave the path, such as `registerProviders("src/shared/components")`
128
+ * -- and the child missing, and then waited for without a limit: content that arrives late still
129
+ * resolves, as it always has. The warning comes once per path: a child further down that is late
130
+ * too is the same wait, and is waited for without a second one.
131
+
132
+ ]]
133
+ local function resolveRbxPath(rbxPath, caller)
134
+ local warned = false
135
+ return walkRbxPath(rbxPath, function(parent, name)
136
+ if warned then
137
+ return parent:WaitForChild(name)
138
+ end
139
+ local child = waitForChild(parent, name, MISSING_CHILD_WARNING)
140
+ if child ~= nil then
141
+ return child
142
+ end
143
+ warned = true
144
+ local waiting = if caller ~= nil then `{caller} is still waiting for its folder` else "Flamework is still waiting for a folder"
145
+ warn(`{waiting}: the build put it at {table.concat(rbxPath, "/")}, ` .. `and {parent:GetFullName()} has no child named '{name}' after {MISSING_CHILD_WARNING} seconds. ` .. "The path may be misspelled or differ in case from the folder, or the folder may be empty and missing from " .. "this clone, since git keeps no empty folder (the build warns about these where the path is used); or " .. "the folder was moved or renamed after the build, or the Rojo project the place was built from leaves it " .. "out. It keeps waiting.")
146
+ return parent:WaitForChild(name)
147
+ end).found
148
+ end
149
+ --[[
150
+ *
151
+ * Walks a compile-time path as {@link resolveRbxPath} does, but gives up on a child that is not
152
+ * there instead of waiting for it forever. A client still loading the place waits for it to load
153
+ * first, since the place's content arrives as it loads; after that, a missing child is given
154
+ * `timeout` seconds to appear.
155
+ *
156
+ * Returns the instance the path names, or the deepest instance it found and the name missing below
157
+ * it.
158
+
159
+ ]]
160
+ local function findRbxPath(rbxPath, timeout)
161
+ return walkRbxPath(rbxPath, function(parent, name)
162
+ return waitForChild(parent, name, timeout)
163
+ end)
89
164
  end
90
165
  --[[
91
166
  *
@@ -101,5 +176,6 @@ end
101
176
  return {
102
177
  getPathRoot = getPathRoot,
103
178
  resolveRbxPath = resolveRbxPath,
179
+ findRbxPath = findRbxPath,
104
180
  __setPathRoot = __setPathRoot,
105
181
  }
package/package.json CHANGED
@@ -1,19 +1,26 @@
1
1
  {
2
2
  "name": "@flamework-experimental/core",
3
- "version": "2.0.0-alpha.2",
3
+ "version": "2.0.0-alpha.4",
4
4
  "main": "out/init.luau",
5
5
  "types": "out/index.d.ts",
6
- "scripts": {
7
- "build": "rbxtsc",
8
- "watch": "rbxtsc -w"
9
- },
10
6
  "repository": {
11
7
  "type": "git",
12
- "url": "git+https://github.com/rbxts-flamework/core.git"
8
+ "url": "git+https://github.com/Velover/ExperimentalFlameworkV2.git",
9
+ "directory": "packages/core"
10
+ },
11
+ "homepage": "https://github.com/Velover/ExperimentalFlameworkV2#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/Velover/ExperimentalFlameworkV2/issues"
14
+ },
15
+ "scripts": {
16
+ "build": "rbxtsc",
17
+ "watch": "rbxtsc -w",
18
+ "prepack": "node ../../scripts/copy-readme.mjs && node ../../scripts/copy-docs.mjs"
13
19
  },
14
20
  "files": [
15
21
  "out",
16
- "flamework.build"
22
+ "flamework.build",
23
+ "docs"
17
24
  ],
18
25
  "publishConfig": {
19
26
  "access": "public"