@papercraftgames/estragon 0.1.0-beta.2 → 0.1.0-beta.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 (41) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/README.md +9 -8
  3. package/addons/estragon/compiler/bindable.gd +3 -3
  4. package/addons/estragon/compiler/compiler.gd +8 -8
  5. package/addons/estragon/compiler/composition.gd +5 -4
  6. package/addons/estragon/compiler/emitter.gd +22 -7
  7. package/addons/estragon/compiler/frontend.gd +8 -8
  8. package/addons/estragon/compiler/lexer.gd +2 -2
  9. package/addons/estragon/compiler/native/resolver.gd +7 -7
  10. package/addons/estragon/compiler/parser.gd +3 -3
  11. package/addons/estragon/compiler/script_validation.gd +3 -3
  12. package/addons/estragon/compiler/source.gd +9 -2
  13. package/addons/estragon/compiler/source_map.gd +2 -2
  14. package/addons/estragon/compiler/validator.gd +6 -5
  15. package/addons/estragon/editor/build_service.gd +4 -4
  16. package/addons/estragon/editor/highlighter.gd +1 -1
  17. package/addons/estragon/editor/highlighter_association.gd +1 -1
  18. package/addons/estragon/editor/plugin.cfg +1 -1
  19. package/addons/estragon/editor/plugin.gd +4 -4
  20. package/addons/estragon/editor/script_dependencies.gd +2 -2
  21. package/addons/estragon/runtime/composition/binding.gd +1 -1
  22. package/addons/estragon/runtime/composition/computation.gd +3 -3
  23. package/addons/estragon/runtime/composition/element.gd +1 -1
  24. package/addons/estragon/runtime/composition/profile.tres +1 -1
  25. package/addons/estragon/runtime/composition/state.gd +2 -2
  26. package/addons/estragon/runtime/composition/state.tres +1 -1
  27. package/addons/estragon/runtime/node/button.gd +1 -1
  28. package/addons/estragon/runtime/node/component_2d.gd +1 -1
  29. package/addons/estragon/runtime/node/component_3d.gd +1 -1
  30. package/addons/estragon/runtime/node/estragon_2d.gd +2 -2
  31. package/addons/estragon/runtime/node/estragon_3d.gd +1 -1
  32. package/addons/estragon/runtime/node/hbox.gd +1 -1
  33. package/addons/estragon/runtime/node/internal/coordinator.gd +2 -2
  34. package/addons/estragon/runtime/node/internal/layout_core.gd +1 -1
  35. package/addons/estragon/runtime/node/native_2d.gd +2 -2
  36. package/addons/estragon/runtime/node/native_3d.gd +2 -2
  37. package/addons/estragon/runtime/node/rect.gd +1 -1
  38. package/addons/estragon/runtime/node/text.gd +1 -1
  39. package/addons/estragon/runtime/node/toggle.gd +1 -1
  40. package/addons/estragon/runtime/node/vbox.gd +1 -1
  41. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  ## Next automated prerelease
4
4
 
5
- No compiler/runtime behavior changes are introduced by the packaging and version-source correction. The **one** release version is set in the Godot plugin configuration; the npm manifest is generated from it during packaging. The owner-controlled GitHub prerelease will exercise npm OIDC trusted publishing, provenance, byte-for-byte package verification and the approved Linux Godot consumer checks. These publication checks remain pending until the release actually runs.
5
+ P02 makes runtime/compiler/editor dependencies location-independent and derives injected Gogo dependencies from the installed Resources and actual generated destination. Yarn packages run directly in node_modules; full-path plugin activation, cold editor/Play, nonstandard relocation and standard addon placement are covered by native consumer acceptance. This change is not yet published. The **one** release version is set in the Godot plugin configuration; the npm manifest is generated from it during packaging. The owner-controlled GitHub prerelease will exercise npm OIDC trusted publishing, provenance, byte-for-byte package verification and the approved Linux Godot consumer checks. These publication checks remain pending until the release actually runs.
6
6
 
7
7
  ## Initial public beta
8
8
 
9
9
  The first curated `@papercraftgames/estragon` addon artifact was published locally after merged F01–F06. It includes the bundled Gogo/GGX compiler/editor, typed/class-wide bindables, a signal-driven description reconciler, conditional/keyed retained Nodes, a native boolean two-way toggle, layout-first 2D widgets, bounded 3D adapters, opt-in profiling and measured LIS/preflight improvements.
10
10
 
11
- No JavaScript compiler/runtime or lifecycle scripts. Yarn dependency acquisition requires an explicit copy to the Godot project's `addons/estragon` and a `node_modules/.gdignore`. This is an early beta, not complete UI framework or release certification. Verified source/engines/artifact evidence and limitations remain in issue #104.
11
+ No JavaScript compiler/runtime or lifecycle scripts. The initial artifact used the former relocated-addon install contract; P02 replaces it with direct Yarn consumption. This is an early beta, not complete UI framework or release certification. Verified source/engines/artifact evidence and limitations remain in issue #104.
package/README.md CHANGED
@@ -4,23 +4,24 @@ Pre-1.0 Godot addon: native Gogo/GGX compilation/editor, signal-driven descripti
4
4
 
5
5
  ## Install into a Godot project
6
6
 
7
- Install the currently published beta with Yarn. The `beta` dist-tag resolves to the published package; `--exact` pins its resolved version in the consumer's manifest:
7
+ P02 direct-install support is pending an owner-published release; earlier public betas may not contain this fix. The following contract applies to a package containing P02. Install the current beta in the Godot project root:
8
8
 
9
9
  ```sh
10
10
  yarn add --exact --ignore-scripts @papercraftgames/estragon@beta
11
11
  ```
12
12
 
13
- Yarn alone installs into `node_modules`; it does not register a Godot plugin. From the project root, with no existing `addons/estragon` directory:
13
+ Keep the package where Yarn installs it. Do not copy, symlink or ignore the addon. Before opening the editor, add its full configuration path to the existing `editor_plugins/enabled` list in `project.godot` (preserve other enabled plugins):
14
14
 
15
- ```sh
16
- touch node_modules/.gdignore
17
- mkdir -p addons
18
- cp -R node_modules/@papercraftgames/estragon/addons/estragon addons/estragon
15
+ ```ini
16
+ [editor_plugins]
17
+ enabled=PackedStringArray("res://node_modules/@papercraftgames/estragon/addons/estragon/editor/plugin.cfg")
19
18
  ```
20
19
 
21
- The `.gdignore` prevents Godot importing a duplicate copy from node_modules. Use a copy, not a source/output symlink. For upgrades, back up local addon modifications and deliberately replace the previous addon directory; do not nest/merge two addon versions. Commit the copied addon and its `.gd.uid` sidecars. A teammate receiving that project can edit/run with Godot alone; node_modules is not needed at runtime.
20
+ Godot's Plugins panel discovers candidates under `addons/`; the enabled-plugin project setting accepts a full `res://` configuration path outside that directory. Yarn installation alone does not enable the plugin. Install dependencies before opening Godot; keep only one Estragon tree to avoid duplicate classes/UIDs. Commit the package manifest/lockfile and plugin setting, retaining the package's stable `.gd.uid` sidecars. Godot alone handles editing and Play after installation.
21
+
22
+ Explicit authored preload aliases reference the chosen installation, for example `preload("../../../node_modules/@papercraftgames/estragon/addons/estragon/runtime/composition/element.gd")` in a Gogo file whose generated script lives three directories below the project root. As with ordinary GDScript, relative authored imports resolve from the **generated script's directory**. Canonical registered widget class names also work after Godot indexes the project. Internal dependencies are script-relative; compiler-injected dependencies are calculated from installed Resources and the actual output directory. A different project-relative installation needs only matching authored imports and the plugin configuration setting; no production source edits. Standard `addons/estragon` placement remains supported.
22
23
 
23
- Open Godot → Project Settings → Plugins and enable **Estragon** at `res://addons/estragon/editor/plugin.cfg`. Author `.gogo` files and normal `.tscn` hosts referencing the generated script. Optionally put `{"version":1,"source_roots":["src"]}` in project `gogo.config.json`. Normal save and both main/current Play paths compile and validate natively; invalid or unsavable source blocks stale Play and recovers after repair.
24
+ Author `.gogo` files and normal `.tscn` hosts referencing generated scripts. Optional `gogo.config.json`: `{"version":1,"source_roots":["src"]}`. Native save and main/current Play compile with actual-path validation, invalid/unsavable-source rejection, rollback and repair. Generated files must be rebuilt after relocating an installed addon, just as authored imports must be updated.
24
25
 
25
26
  [Source-authored Counter example](https://github.com/papercraftgames/Estragon/tree/main/examples/counter), [language](https://github.com/papercraftgames/Estragon/blob/main/docs/GOGO_LANGUAGE.md), [native UI](https://github.com/papercraftgames/Estragon/blob/main/docs/NODE_UI.md), [editor](https://github.com/papercraftgames/Estragon/blob/main/docs/EDITOR.md), [package/release contract](https://github.com/papercraftgames/Estragon/blob/main/docs/PACKAGING.md).
26
27
 
@@ -1,9 +1,9 @@
1
1
  @tool
2
2
  extends RefCounted
3
3
  ## One lexical property lowering for explicit and class-wide Gogo annotations.
4
- const Model = preload("res://addons/estragon/compiler/model.gd")
5
- const Source = preload("res://addons/estragon/compiler/source.gd")
6
- const Lexer = preload("res://addons/estragon/compiler/lexer.gd")
4
+ const Model = preload("model.gd")
5
+ const Source = preload("source.gd")
6
+ const Lexer = preload("lexer.gd")
7
7
  var file: Source
8
8
  var module: Model.Module
9
9
  var members: Dictionary = {}
@@ -1,11 +1,11 @@
1
1
  @tool
2
2
  extends RefCounted
3
3
  ## Pure native compilation. Semantic validation/loading is an explicit next step.
4
- const Model = preload("res://addons/estragon/compiler/model.gd")
5
- const Source = preload("res://addons/estragon/compiler/source.gd")
6
- const Frontend = preload("res://addons/estragon/compiler/frontend.gd")
7
- const Emitter = preload("res://addons/estragon/compiler/emitter.gd")
8
- const SourceMap = preload("res://addons/estragon/compiler/source_map.gd")
4
+ const Model = preload("model.gd")
5
+ const Source = preload("source.gd")
6
+ const Frontend = preload("frontend.gd")
7
+ const Emitter = preload("emitter.gd")
8
+ const SourceMap = preload("source_map.gd")
9
9
 
10
10
  class Compilation extends RefCounted:
11
11
  var code: String
@@ -14,11 +14,11 @@ class Compilation extends RefCounted:
14
14
  var ok: bool:
15
15
  get: return diagnostics.is_empty() and source_map != null
16
16
 
17
- static func compile(source: String, source_name: String = "<source>") -> Compilation:
17
+ static func compile(source: String, source_name: String = "<source>", output_path: String = "") -> Compilation:
18
18
  var result := Compilation.new()
19
- var frontend := Frontend.analyze(source, source_name)
19
+ var frontend := Frontend.analyze(source, source_name, output_path)
20
20
  result.diagnostics = frontend.diagnostics
21
21
  if not frontend.ok: return result
22
- result.source_map = Emitter.new(frontend.module, Source.new(source, source_name)).emit()
22
+ result.source_map = Emitter.new(frontend.module, Source.new(source, source_name, output_path)).emit()
23
23
  result.code = result.source_map.code
24
24
  return result
@@ -1,9 +1,10 @@
1
1
  @tool
2
2
  extends RefCounted
3
3
  ## Detect the automatic host entry. Every GGX expression is a description.
4
- const Model = preload("res://addons/estragon/compiler/model.gd")
5
- const Lexer = preload("res://addons/estragon/compiler/lexer.gd")
6
- const Resolver = preload("res://addons/estragon/compiler/native/resolver.gd")
4
+ const Element = preload("../runtime/composition/element.gd")
5
+ const Model = preload("model.gd")
6
+ const Lexer = preload("lexer.gd")
7
+ const Resolver = preload("native/resolver.gd")
7
8
  var file
8
9
  func _init(source) -> void:
9
10
  file = source
@@ -31,7 +32,7 @@ func apply(module) -> void:
31
32
  return
32
33
  continue
33
34
  var type: String = tokens[index+5].text
34
- if resolver.aliases.get(type,"")!="res://addons/estragon/runtime/composition/element.gd":
35
+ if resolver.aliases.get(type,"")!=(Element as Script).resource_path:
35
36
  if has_ggx and type in ["Node","Node2D","Node3D"]:
36
37
  file.fail("build_view must return Element descriptions; eager Node-returning GGX is unsupported",tokens[index+5].span.start.index,tokens[index+5].span.end.index)
37
38
  return
@@ -1,9 +1,12 @@
1
1
  @tool
2
2
  extends RefCounted
3
3
  ## Typed frontend -> ordinary GDScript. All output is range-mapped, never rewritten.
4
- const Model = preload("res://addons/estragon/compiler/model.gd")
5
- const Source = preload("res://addons/estragon/compiler/source.gd")
6
- const MappedWriter = preload("res://addons/estragon/compiler/source_map.gd")
4
+ const Element = preload("../runtime/composition/element.gd")
5
+ const State = preload("../runtime/composition/state.tres")
6
+ const Binding = preload("../runtime/composition/binding.gd")
7
+ const Model = preload("model.gd")
8
+ const Source = preload("source.gd")
9
+ const MappedWriter = preload("source_map.gd")
7
10
 
8
11
  class Argument extends RefCounted:
9
12
  var expression: Model.GdExpression
@@ -16,6 +19,7 @@ class Factory extends RefCounted:
16
19
  var root: Model.Component
17
20
  var arguments: Array[Argument] = []
18
21
 
22
+ var _output_directory: String
19
23
  var _module: Model.Module
20
24
  var _file: Source
21
25
  var _writer: MappedWriter
@@ -27,6 +31,10 @@ var _factory_class: String
27
31
  var _element_class: String
28
32
 
29
33
  func _init(module: Model.Module, file: Source) -> void:
34
+ # Paths are relative to the actual generated file, derived from installed Resources.
35
+ # Pathless in-memory callers use the project root, as native GDScript does.
36
+ _output_directory = file.generated_path().get_base_dir()
37
+ if not _output_directory.is_absolute_path(): _output_directory = "res://" + _output_directory
30
38
  _module = module
31
39
  _file = file
32
40
  _writer = MappedWriter.new(file)
@@ -40,14 +48,21 @@ func _init(module: Model.Module, file: Source) -> void:
40
48
  _element_class = "_GogoElement_0"
41
49
  while _module.identifiers.has(_element_class): _element_class += "_"
42
50
 
51
+ func _resource(resource: Resource) -> String:
52
+ var origin := ProjectSettings.globalize_path(_output_directory).simplify_path().split("/", false)
53
+ var target := ProjectSettings.globalize_path(resource.resource_path).simplify_path().split("/", false)
54
+ var shared := 0
55
+ while shared < mini(origin.size(), target.size()) and origin[shared] == target[shared]: shared += 1
56
+ return _string("../".repeat(origin.size() - shared) + "/".join(target.slice(shared)))
57
+
43
58
  func emit() -> MappedWriter:
44
59
  _parts(_module.parts)
45
60
  _writer.append("\n")
46
61
  if _module.composition:
47
- _writer.append("\nfunc _notification(_gogo_what: int) -> void:\n"+_module.indentation+"preload(\"res://addons/estragon/runtime/composition/state.tres\").lifecycle(self, _gogo_what)\n")
62
+ _writer.append("\nfunc _notification(_gogo_what: int) -> void:\n"+_module.indentation+"preload("+_resource(State)+").lifecycle(self, _gogo_what)\n")
48
63
  if not _factories.is_empty():
49
64
  _writer.append("\n\nclass " + _factory_class + ":", _factories[0].root.span)
50
- _writer.append("\n"+_module.indentation+"const "+_element_class+" = preload(\"res://addons/estragon/runtime/composition/element.gd\")\n")
65
+ _writer.append("\n"+_module.indentation+"const "+_element_class+" = preload("+_resource(Element)+")\n")
51
66
  # Calls in argument expressions may append additional factories.
52
67
  var index: int = 0
53
68
  while index < _factories.size():
@@ -190,7 +205,7 @@ func _bindable(property: Model.Bindable) -> void:
190
205
  _writer.append(indent.repeat(2)+"var "+previous+": "+property.type_name+" = "+property.name+"\n",property.name_span)
191
206
  _writer.append(indent.repeat(2)+property.name+" = "+incoming+"\n",property.name_span)
192
207
  _writer.append(indent.repeat(2)+property.signal_name+".emit("+previous+", "+incoming+")\n",property.name_span)
193
- _writer.append(indent+"get:\n"+indent.repeat(2)+"preload(\"res://addons/estragon/runtime/composition/state.tres\").observe(self, &"+_string(property.signal_name)+")\n"+indent.repeat(2)+"return "+property.name+"\n",property.name_span)
208
+ _writer.append(indent+"get:\n"+indent.repeat(2)+"preload("+_resource(State)+").observe(self, &"+_string(property.signal_name)+")\n"+indent.repeat(2)+"return "+property.name+"\n",property.name_span)
194
209
 
195
210
  func _binding_argument(argument: Argument) -> void:
196
211
  var path := argument.binding_path.duplicate()
@@ -206,4 +221,4 @@ func _binding_argument(argument: Argument) -> void:
206
221
  for name in path:
207
222
  endpoint += "."+str(name)
208
223
  checks.append(endpoint+" != null")
209
- _writer.append("preload(\"res://addons/estragon/runtime/composition/binding.gd\").new(self, func("+owner+"): return "+endpoint+" if "+" and ".join(checks)+" else null, "+_string(field)+", func("+source+", "+edit+": bool): "+source+"."+field+" = "+edit+", "+_string(".".join(argument.binding_path))+")",argument.expression.span)
224
+ _writer.append("preload("+_resource(Binding)+").new(self, func("+owner+"): return "+endpoint+" if "+" and ".join(checks)+" else null, "+_string(field)+", func("+source+", "+edit+": bool): "+source+"."+field+" = "+edit+", "+_string(".".join(argument.binding_path))+")",argument.expression.span)
@@ -1,15 +1,15 @@
1
1
  @tool
2
2
  extends RefCounted
3
3
  ## Native source -> typed frontend result. No emitter, subprocess or editor state.
4
- const Model = preload("res://addons/estragon/compiler/model.gd")
5
- const Source = preload("res://addons/estragon/compiler/source.gd")
6
- const Parser = preload("res://addons/estragon/compiler/parser.gd")
7
- const Bindable = preload("res://addons/estragon/compiler/bindable.gd")
8
- const Validator = preload("res://addons/estragon/compiler/validator.gd")
9
- const Composition = preload("res://addons/estragon/compiler/composition.gd")
4
+ const Model = preload("model.gd")
5
+ const Source = preload("source.gd")
6
+ const Parser = preload("parser.gd")
7
+ const Bindable = preload("bindable.gd")
8
+ const Validator = preload("validator.gd")
9
+ const Composition = preload("composition.gd")
10
10
 
11
- static func analyze(text: String, source_name: String = "<source>") -> Model.Result:
12
- var file := Source.new(text, source_name)
11
+ static func analyze(text: String, source_name: String = "<source>", output_path: String = "") -> Model.Result:
12
+ var file := Source.new(text, source_name, output_path)
13
13
  var parser := Parser.new(file)
14
14
  var result := Model.Result.new()
15
15
  var module := parser.parse()
@@ -2,8 +2,8 @@
2
2
  extends RefCounted
3
3
  ## Re-entrant token scanner: caller supplies the offset and lexical context.
4
4
  ## Regexes classify Unicode characters only; no source rewriting/evaluation.
5
- const Model = preload("res://addons/estragon/compiler/model.gd")
6
- const Source = preload("res://addons/estragon/compiler/source.gd")
5
+ const Model = preload("model.gd")
6
+ const Source = preload("source.gd")
7
7
  const OPERATORS := ["**=", "<<=", ">>=", ":=", "==", "!=", "<=", ">=", "<<", ">>", "**", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "&&", "||", "->"]
8
8
  var file: Source
9
9
  var tokens: Array[Model.Token] = []
@@ -1,11 +1,11 @@
1
1
  @tool
2
2
  extends RefCounted
3
3
  ## Static Node type metadata. Never instantiate authored classes or use editor/tree.
4
- const Model = preload("res://addons/estragon/compiler/model.gd")
5
- const Lexer = preload("res://addons/estragon/compiler/lexer.gd")
6
- const Source = preload("res://addons/estragon/compiler/source.gd")
7
- const Parser = preload("res://addons/estragon/compiler/parser.gd")
8
- const Bindable = preload("res://addons/estragon/compiler/bindable.gd")
4
+ const Model = preload("../model.gd")
5
+ const Lexer = preload("../lexer.gd")
6
+ const Source = preload("../source.gd")
7
+ const Parser = preload("../parser.gd")
8
+ const Bindable = preload("../bindable.gd")
9
9
  var visiting: Dictionary = {}
10
10
  var file
11
11
  var aliases: Dictionary = {}
@@ -48,9 +48,9 @@ func scan(module: Model.Module) -> void:
48
48
  return
49
49
  var path: String = literal.call("value")
50
50
  if not path.is_absolute_path():
51
- var output: String = file.name.get_base_dir().path_join("generated").path_join(file.name.get_file().get_basename() + ".gd")
51
+ var output: String = file.generated_path()
52
52
  path = output.get_base_dir().path_join(path).simplify_path()
53
- if not path.begins_with("res://"): path = "res://" + path
53
+ if not path.is_absolute_path(): path = "res://" + path
54
54
  aliases[name] = path
55
55
 
56
56
  func resolve(name: String, span: Model.Span) -> Dictionary:
@@ -1,9 +1,9 @@
1
1
  @tool
2
2
  extends RefCounted
3
3
  ## Recursive-descent component islands composed with lexically retained GDScript.
4
- const Model = preload("res://addons/estragon/compiler/model.gd")
5
- const Source = preload("res://addons/estragon/compiler/source.gd")
6
- const Lexer = preload("res://addons/estragon/compiler/lexer.gd")
4
+ const Model = preload("model.gd")
5
+ const Source = preload("source.gd")
6
+ const Lexer = preload("lexer.gd")
7
7
  const OPERANDS := ["return", "yield", "await", "if", "elif", "else", "while", "in", "and", "or", "not", "assert", "match"]
8
8
  const OPEN := {"(": ")", "[": "]", "{": "}"}
9
9
  var file: Source
@@ -2,8 +2,8 @@
2
2
  extends RefCounted
3
3
  ## Explicit Godot semantic validation, separate from deterministic source emission.
4
4
  ## Uses native Logger only for the synchronous reload window; never spawns tools.
5
- const Model = preload("res://addons/estragon/compiler/model.gd")
6
- const Compiler = preload("res://addons/estragon/compiler/compiler.gd")
5
+ const Model = preload("model.gd")
6
+ const Compiler = preload("compiler.gd")
7
7
 
8
8
  class Validation extends RefCounted:
9
9
  var generated_script: GDScript
@@ -19,7 +19,7 @@ static func _capture(path: String) -> Object:
19
19
  if not OS.has_method("add_logger") or not OS.has_method("remove_logger"):
20
20
  return null
21
21
  var factory := GDScript.new()
22
- factory.source_code = FileAccess.get_file_as_string("res://addons/estragon/compiler/diagnostic_capture.gd.txt")
22
+ factory.source_code = FileAccess.get_file_as_string((Compiler as Script).resource_path.get_base_dir().path_join("diagnostic_capture.gd.txt"))
23
23
  if factory.reload() != OK: return null # Native errors remain visible.
24
24
  var logger = factory.new()
25
25
  logger.path = path
@@ -1,21 +1,28 @@
1
1
  @tool
2
2
  extends RefCounted
3
3
  ## Source ranges use code-point indexes internally and compatible UTF-16 externally.
4
- const Model = preload("res://addons/estragon/compiler/model.gd")
4
+ const Model = preload("model.gd")
5
5
  var text: String
6
6
  var name: String
7
+ var output_path: String
7
8
  var diagnostics: Array[Model.Diagnostic] = []
8
9
  var _lines: PackedInt32Array = [0]
9
10
  var _utf16: PackedInt32Array = [0]
10
11
 
11
- func _init(value: String, source_name: String = "<source>") -> void:
12
+ func _init(value: String, source_name: String = "<source>", generated_path: String = "") -> void:
12
13
  text = value
13
14
  name = source_name
15
+ output_path = generated_path
14
16
  for index in range(text.length()):
15
17
  _utf16.append(_utf16[-1] + (2 if text.unicode_at(index) > 0xffff else 1))
16
18
  if text[index] == "\n" or text[index] == "\r" and (index + 1 == text.length() or text[index + 1] != "\n"):
17
19
  _lines.append(index + 1)
18
20
 
21
+ func generated_path() -> String:
22
+ if not output_path.is_empty(): return output_path
23
+ if not "/" in name: return "res://Generated.gd"
24
+ return name.get_base_dir().path_join("generated").path_join(name.get_file().get_basename() + ".gd")
25
+
19
26
  func position(index: int) -> Model.Position:
20
27
  index = clampi(index, 0, text.length())
21
28
  var low: int = 0
@@ -1,8 +1,8 @@
1
1
  @tool
2
2
  extends RefCounted
3
3
  ## Version-1 range maps, shared by native generation and diagnostic consumers.
4
- const Model = preload("res://addons/estragon/compiler/model.gd")
5
- const Source = preload("res://addons/estragon/compiler/source.gd")
4
+ const Model = preload("model.gd")
5
+ const Source = preload("source.gd")
6
6
  var source: Source
7
7
  var code: String
8
8
  var segments: Array[Dictionary] = []
@@ -1,10 +1,11 @@
1
1
  @tool
2
2
  extends RefCounted
3
3
  ## Static native Node property/signal contracts; no SceneTree or editor dependency.
4
- const Model = preload("res://addons/estragon/compiler/model.gd")
5
- const Source = preload("res://addons/estragon/compiler/source.gd")
6
- const Resolver = preload("res://addons/estragon/compiler/native/resolver.gd")
7
- const Lexer = preload("res://addons/estragon/compiler/lexer.gd")
4
+ const Element = preload("../runtime/composition/element.gd")
5
+ const Model = preload("model.gd")
6
+ const Source = preload("source.gd")
7
+ const Resolver = preload("native/resolver.gd")
8
+ const Lexer = preload("lexer.gd")
8
9
  var file: Source
9
10
  var resolver
10
11
  var current_module
@@ -231,7 +232,7 @@ func _child_result(tokens: Array, span) -> void:
231
232
  var first: String = tokens[0].text
232
233
  var constructor: bool = tokens.size()>3 and tokens[1].text=="." and tokens[2].text=="new" and tokens[3].text=="(" and _direct_call(tokens,3)
233
234
  var scalar_call: bool = tokens.size()>1 and tokens[1].text=="(" and _direct_call(tokens,1) and first in ["int","float","bool","String","StringName","Vector2","Vector3","Color","Dictionary","NodePath"]
234
- if tokens[0].kind=="identifier" and first not in ["true","false"] and not scalar_call and (not constructor or resolver.aliases.get(first,"")=="res://addons/estragon/runtime/composition/element.gd"):
235
+ if tokens[0].kind=="identifier" and first not in ["true","false"] and not scalar_call and (not constructor or resolver.aliases.get(first,"")==(Element as Script).resource_path):
235
236
  return
236
237
  _error("GGX children require Element, null or nested Arrays of descriptions; scalars/live Nodes reject",tokens[0].span if not tokens.is_empty() else span)
237
238
 
@@ -1,9 +1,9 @@
1
1
  @tool
2
2
  extends RefCounted
3
3
  ## Native project build. No editor UI, processes or external tool configuration.
4
- const Compiler = preload("res://addons/estragon/compiler/compiler.gd")
5
- const Validation = preload("res://addons/estragon/compiler/script_validation.gd")
6
- const Dependencies = preload("res://addons/estragon/editor/script_dependencies.gd")
4
+ const Compiler = preload("../compiler/compiler.gd")
5
+ const Validation = preload("../compiler/script_validation.gd")
6
+ const Dependencies = preload("script_dependencies.gd")
7
7
  const CONFIG := "gogo.config.json"
8
8
  const EXCLUDED := ["generated", "node_modules", "tests", "vendor"]
9
9
  var _project: String
@@ -91,7 +91,7 @@ func _run() -> Dictionary:
91
91
  if input == null:
92
92
  _fail(source + ": cannot read source (" + error_string(FileAccess.get_open_error()) + ")")
93
93
  continue
94
- var result := Compiler.compile(input.get_as_text(), source)
94
+ var result := Compiler.compile(input.get_as_text(), source, _resource_path(output_for(source)))
95
95
  if not result.ok:
96
96
  for diagnostic in result.diagnostics: _fail(diagnostic.format())
97
97
  else: compiled.append({"source": source, "output": output_for(source), "result": result})
@@ -14,7 +14,7 @@ var _lines: Array[Dictionary] = []
14
14
 
15
15
 
16
16
  func _create() -> EditorSyntaxHighlighter:
17
- return load("res://addons/estragon/editor/highlighter.gd").new()
17
+ return get_script().new()
18
18
 
19
19
 
20
20
  func _get_name() -> String:
@@ -2,7 +2,7 @@
2
2
  extends RefCounted
3
3
  ## Repair extension association after native tab creation / cached state restore.
4
4
  ## Kept separate from compilation; no timer, file writes or editor preferences.
5
- const Highlighter = preload("res://addons/estragon/editor/highlighter.gd")
5
+ const Highlighter = preload("highlighter.gd")
6
6
  const PATH_META := "estragon_gogo_path"
7
7
  var _scripts: ScriptEditor
8
8
  var _tree: SceneTree
@@ -3,5 +3,5 @@
3
3
  name="Estragon"
4
4
  description="Native Gogo/GGX highlighting, compilation and validation before Play."
5
5
  author="Resist Design"
6
- version="0.1.0-beta.2"
6
+ version="0.1.0-beta.4"
7
7
  script="plugin.gd"
@@ -2,10 +2,10 @@
2
2
  extends EditorPlugin
3
3
  ## Native ScriptEditor authoring and direct Godot compilation before every Play.
4
4
 
5
- const BufferGuard = preload("res://addons/estragon/editor/buffer_guard.gd")
6
- const BuildService = preload("res://addons/estragon/editor/build_service.gd")
7
- const HighlighterAssociation = preload("res://addons/estragon/editor/highlighter_association.gd")
8
- const Highlighter = preload("res://addons/estragon/editor/highlighter.gd")
5
+ const BufferGuard = preload("buffer_guard.gd")
6
+ const BuildService = preload("build_service.gd")
7
+ const HighlighterAssociation = preload("highlighter_association.gd")
8
+ const Highlighter = preload("highlighter.gd")
9
9
  const TEXT_EXTENSIONS_SETTING := "docks/filesystem/textfile_extensions"
10
10
 
11
11
  var _highlighter: EditorSyntaxHighlighter
@@ -2,8 +2,8 @@
2
2
  extends RefCounted
3
3
  ## Static resource edges for ordering native validation/reloads. Reuses N01's
4
4
  ## lexer; Godot decodes string literals and remains the semantic authority.
5
- const Lexer = preload("res://addons/estragon/compiler/lexer.gd")
6
- const Source = preload("res://addons/estragon/compiler/source.gd")
5
+ const Lexer = preload("../compiler/lexer.gd")
6
+ const Source = preload("../compiler/source.gd")
7
7
 
8
8
  static func paths(code: String, output: String) -> PackedStringArray:
9
9
  var file := Source.new(code)
@@ -1,6 +1,6 @@
1
1
  @tool
2
2
  extends RefCounted
3
- const Profile = preload("res://addons/estragon/runtime/composition/profile.tres")
3
+ const Profile = preload("profile.tres")
4
4
  ## Desired typed linkage, owned only by external description/mount records.
5
5
  var root: WeakRef
6
6
  var source: WeakRef
@@ -1,8 +1,8 @@
1
1
  extends RefCounted
2
- const Profile = preload("res://addons/estragon/runtime/composition/profile.tres")
2
+ const Profile = preload("profile.tres")
3
3
  ## F01 computation and retained static-shape records external to native objects.
4
- const Binding = preload("res://addons/estragon/runtime/composition/binding.gd")
5
- const Element = preload("res://addons/estragon/runtime/composition/element.gd")
4
+ const Binding = preload("binding.gd")
5
+ const Element = preload("element.gd")
6
6
  class Mounted extends RefCounted:
7
7
  var node: WeakRef
8
8
  var type: Variant
@@ -1,6 +1,6 @@
1
1
  @tool
2
2
  extends RefCounted
3
- const Profile = preload("res://addons/estragon/runtime/composition/profile.tres")
3
+ const Profile = preload("profile.tres")
4
4
  ## Desired values only. No native Node is allocated during description creation.
5
5
  var type: Variant
6
6
  var properties: Dictionary
@@ -1,6 +1,6 @@
1
1
  [gd_resource type="Resource" load_steps=2 format=3]
2
2
 
3
- [ext_resource type="Script" path="res://addons/estragon/runtime/composition/profile.gd" id="1"]
3
+ [ext_resource type="Script" path="profile.gd" id="1"]
4
4
 
5
5
  [resource]
6
6
  script = ExtResource("1")
@@ -1,6 +1,6 @@
1
1
  @tool
2
2
  extends Resource
3
- const Profile = preload("res://addons/estragon/runtime/composition/profile.tres")
3
+ const Profile = preload("profile.tres")
4
4
  ## Framework-owned shared scope stack; never stored on application objects.
5
5
  var scopes: Array = []
6
6
  var records: Dictionary = {}
@@ -48,7 +48,7 @@ func lifecycle(host: Node, what: int) -> void:
48
48
  var id := host.get_instance_id()
49
49
  if what == Node.NOTIFICATION_READY:
50
50
  if not records.has(id):
51
- var record = preload("res://addons/estragon/runtime/composition/computation.gd").new(host,self)
51
+ var record = preload("computation.gd").new(host,self)
52
52
  records[id] = record
53
53
  record.schedule()
54
54
  elif what == Node.NOTIFICATION_ENTER_TREE and records.has(id):
@@ -1,6 +1,6 @@
1
1
  [gd_resource type="Resource" load_steps=2 format=3]
2
2
 
3
- [ext_resource type="Script" path="res://addons/estragon/runtime/composition/state.gd" id="1"]
3
+ [ext_resource type="Script" path="state.gd" id="1"]
4
4
 
5
5
  [resource]
6
6
  script = ExtResource("1")
@@ -1,6 +1,6 @@
1
1
  @tool
2
2
  class_name EstragonButton
3
- extends "res://addons/estragon/runtime/node/text.gd"
3
+ extends "text.gd"
4
4
  ## Native primary-pointer button. No Control widget or polling wrapper.
5
5
  signal pressed
6
6
  const PADDING := Vector2(14,8)
@@ -3,7 +3,7 @@ class_name EstragonComponent2D
3
3
  extends Node2D
4
4
  ## Native C1 participant. Needs a contiguous same-dimensional chain to an entry.
5
5
  signal layout_applied(size: Vector2)
6
- const Coordinator = preload("res://addons/estragon/runtime/node/internal/coordinator.gd")
6
+ const Coordinator = preload("internal/coordinator.gd")
7
7
  @export var width: float = -1.0:
8
8
  set(value):
9
9
  if not valid_length(value) or width == value: return
@@ -3,7 +3,7 @@ class_name EstragonComponent3D
3
3
  extends Node3D
4
4
  ## Native C1 participant. Needs a contiguous same-dimensional chain to an entry.
5
5
  signal layout_applied(size: Vector3)
6
- const Coordinator = preload("res://addons/estragon/runtime/node/internal/coordinator.gd")
6
+ const Coordinator = preload("internal/coordinator.gd")
7
7
  @export var width: float = -1.0:
8
8
  set(value):
9
9
  if not valid_length(value) or width == value: return
@@ -1,6 +1,6 @@
1
1
  @tool
2
2
  class_name Estragon2D
3
- extends "res://addons/estragon/runtime/node/component_2d.gd"
3
+ extends "component_2d.gd"
4
4
  ## Explicit independent layout scope; does not assign native scene owner.
5
5
  @export var viewport_width_scale: float = 0.0:
6
6
  set(value):
@@ -14,7 +14,7 @@ func _is_layout_entry() -> bool:
14
14
  func _layout_viewport_scale() -> float:
15
15
  return viewport_width_scale
16
16
 
17
- const Pointer = preload("res://addons/estragon/runtime/node/internal/pointer_2d.gd")
17
+ const Pointer = preload("internal/pointer_2d.gd")
18
18
  var _pointer = Pointer.new(self)
19
19
 
20
20
  func _get_pointer_router():
@@ -1,6 +1,6 @@
1
1
  @tool
2
2
  class_name Estragon3D
3
- extends "res://addons/estragon/runtime/node/component_3d.gd"
3
+ extends "component_3d.gd"
4
4
  ## Explicit independent layout scope; does not assign native scene owner.
5
5
  @export var viewport_width_scale: float = 0.0:
6
6
  set(value):
@@ -1,6 +1,6 @@
1
1
  @tool
2
2
  class_name EstragonHBox
3
- extends "res://addons/estragon/runtime/node/component_2d.gd"
3
+ extends "component_2d.gd"
4
4
  ## Native stack participant using the shared composed layout algorithm.
5
5
  func _layout_axis() -> int:
6
6
  return 0
@@ -1,8 +1,8 @@
1
1
  @tool
2
2
  extends RefCounted
3
- const Profile = preload("res://addons/estragon/runtime/composition/profile.tres")
3
+ const Profile = preload("../../composition/profile.tres")
4
4
  ## Native event/lifetime adapter shared by both spatial branches. No layout math.
5
- const Core = preload("res://addons/estragon/runtime/node/internal/layout_core.gd")
5
+ const Core = preload("layout_core.gd")
6
6
  const META := "_estragon_b2_coordinator"
7
7
  enum Mode { PROOF, PARTICIPANT, ENTRY }
8
8
  var _mode: int
@@ -1,6 +1,6 @@
1
1
  @tool
2
2
  extends RefCounted
3
- const Profile = preload("res://addons/estragon/runtime/composition/profile.tres")
3
+ const Profile = preload("../../composition/profile.tres")
4
4
  ## Shared B2/C1 mathematical row layout. No Nodes, rendering or SceneTree dependencies.
5
5
  signal invalidated
6
6
  signal placed(offset)
@@ -1,8 +1,8 @@
1
1
  @tool
2
2
  class_name EstragonNative2D
3
- extends "res://addons/estragon/runtime/node/component_2d.gd"
3
+ extends "component_2d.gd"
4
4
  ## C1 bounded native visual participant; allocation never stretches geometry.
5
- const Bounds = preload("res://addons/estragon/runtime/node/internal/native_bounds.gd")
5
+ const Bounds = preload("internal/native_bounds.gd")
6
6
  @export var observe_native: bool = false:
7
7
  set(value):
8
8
  observe_native = value
@@ -1,8 +1,8 @@
1
1
  @tool
2
2
  class_name EstragonNative3D
3
- extends "res://addons/estragon/runtime/node/component_3d.gd"
3
+ extends "component_3d.gd"
4
4
  ## C1 bounded native visual participant; allocation never stretches geometry.
5
- const Bounds = preload("res://addons/estragon/runtime/node/internal/native_bounds.gd")
5
+ const Bounds = preload("internal/native_bounds.gd")
6
6
  @export var observe_native: bool = false:
7
7
  set(value):
8
8
  observe_native = value
@@ -1,6 +1,6 @@
1
1
  @tool
2
2
  class_name EstragonRect
3
- extends "res://addons/estragon/runtime/node/component_2d.gd"
3
+ extends "component_2d.gd"
4
4
  ## Native rectangle drawing. Width/height are inherited layout inputs.
5
5
  @export var fill := Color.WHITE:
6
6
  set(value):
@@ -1,6 +1,6 @@
1
1
  @tool
2
2
  class_name EstragonText
3
- extends "res://addons/estragon/runtime/node/component_2d.gd"
3
+ extends "component_2d.gd"
4
4
  ## Native Font measure/draw, explicit lines only. No wrapping or rich text.
5
5
  @export var text: String = "":
6
6
  set(value):
@@ -1,6 +1,6 @@
1
1
  @tool
2
2
  class_name EstragonToggle
3
- extends "res://addons/estragon/runtime/node/button.gd"
3
+ extends "button.gd"
4
4
  ## Controlled boolean input. Only pointer activation emits a user edit.
5
5
  signal value_changed(value: bool)
6
6
  @export var value: bool = false:
@@ -1,6 +1,6 @@
1
1
  @tool
2
2
  class_name EstragonVBox
3
- extends "res://addons/estragon/runtime/node/component_2d.gd"
3
+ extends "component_2d.gd"
4
4
  ## Native stack participant using the shared composed layout algorithm.
5
5
  func _layout_axis() -> int:
6
6
  return 1
package/package.json CHANGED
@@ -29,5 +29,5 @@
29
29
  "tag": "beta",
30
30
  "registry": "https://registry.npmjs.org/"
31
31
  },
32
- "version": "0.1.0-beta.2"
32
+ "version": "0.1.0-beta.4"
33
33
  }