@stream44.studio/encapsulate 0.4.0-rc.18 → 0.4.0-rc.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream44.studio/encapsulate",
3
- "version": "0.4.0-rc.18",
3
+ "version": "0.4.0-rc.19",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,7 +1,7 @@
1
1
 
2
2
  // CACHE_BUST_VERSION: Increment this whenever CST cache must be invalidated due to structural changes
3
3
  // This ensures projected capsules are regenerated when the CST format changes
4
- const CACHE_BUST_VERSION = 9
4
+ const CACHE_BUST_VERSION = 11
5
5
 
6
6
  type TSpineOptions = {
7
7
  spineFilesystemRoot?: string,
@@ -930,6 +930,10 @@ function extractModuleLocalCode(
930
930
  // Check if this identifier refers to a module-local variable
931
931
  const varDecl = moduleLocalVariables.get(name)
932
932
  if (varDecl) {
933
+ // If already classified as 'literal' with a value, keep it — don't reclassify
934
+ if (refTyped.type === 'literal' && refTyped.value !== undefined) {
935
+ continue
936
+ }
933
937
  // Analyze the variable to see if it's self-contained
934
938
  const varDependencies = analyzeVariableDependencies(varDecl, sourceFile, importMap, assignmentMap, moduleLocalFunctions, moduleLocalVariables)
935
939
  if (varDependencies.isContained) {
@@ -1583,9 +1587,20 @@ function extractCapsuleAmbientReferences(
1583
1587
  }
1584
1588
  }
1585
1589
 
1586
- // Check if it's a module-local variable (const/let/var at module level)
1590
+ // Check if it's a module-local variable (const/let/var at module level or enclosing block)
1587
1591
  const varDecl = moduleLocalVariables.get(identifierName)
1588
1592
  if (varDecl) {
1593
+ // If the runtime value is provided as a literal ambient reference,
1594
+ // prefer 'literal' classification over 'module-local'.
1595
+ // A `const x = 'foo'` in an enclosing block is semantically a literal.
1596
+ if (runtimeAmbientRefs && identifierName in runtimeAmbientRefs) {
1597
+ const value = runtimeAmbientRefs[identifierName]
1598
+ if (isLiteralType(value)) {
1599
+ ambientRefs[identifierName] = { type: 'literal', value }
1600
+ return
1601
+ }
1602
+ }
1603
+
1589
1604
  // Analyze the variable's initializer for dependencies
1590
1605
  const varDependencies = analyzeVariableDependencies(varDecl, sourceFile, importMap, assignmentMap, moduleLocalFunctions, moduleLocalVariables)
1591
1606
 
@@ -1937,6 +1952,17 @@ function extractAndValidateAmbientReferences(
1937
1952
  // Check if it's a module-local variable (const/let/var at module level)
1938
1953
  const varDecl = moduleLocalVariables.get(identifierName)
1939
1954
  if (varDecl) {
1955
+ // If the runtime value is provided as a literal ambient reference,
1956
+ // prefer 'literal' classification over 'module-local'.
1957
+ // A `const x = 'foo'` in an enclosing block is semantically a literal.
1958
+ if (runtimeAmbientRefs && identifierName in runtimeAmbientRefs) {
1959
+ const value = runtimeAmbientRefs[identifierName]
1960
+ if (isLiteralType(value)) {
1961
+ ambientRefs[identifierName] = { type: 'literal', value }
1962
+ return
1963
+ }
1964
+ }
1965
+
1940
1966
  // Analyze the variable's initializer for dependencies
1941
1967
  const varDependencies = analyzeVariableDependencies(varDecl, sourceFile, importMap, assignmentMap, moduleLocalFunctions, moduleLocalVariables)
1942
1968