@reactvision/react-viro 2.56.0 → 2.57.2

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 (106) hide show
  1. package/README.md +8 -0
  2. package/android/react_viro/react_viro-release.aar +0 -0
  3. package/android/viro_renderer/viro_renderer-release.aar +0 -0
  4. package/components/AR/ViroARPlane.tsx +1 -4
  5. package/components/AR/ViroARPlaneSelector.tsx +10 -5
  6. package/components/AR/ViroARScene.tsx +19 -4
  7. package/components/Studio/StudioARScene.tsx +243 -48
  8. package/components/Studio/StudioSceneNavigator.tsx +15 -0
  9. package/components/Studio/VRTStudioModule.ts +10 -0
  10. package/components/Studio/domain/StudioSounds.tsx +46 -0
  11. package/components/Studio/domain/apiRequestHelpers.ts +612 -0
  12. package/components/Studio/domain/collisionBindingsRuntime.ts +17 -2
  13. package/components/Studio/domain/defaultApiRequestExecutor.ts +61 -0
  14. package/components/Studio/domain/expressionEvaluator.ts +603 -0
  15. package/components/Studio/domain/sceneNavigationHandler.ts +770 -20
  16. package/components/Studio/domain/soundManager.ts +141 -0
  17. package/components/Studio/domain/utils.ts +50 -0
  18. package/components/Studio/domain/variableStore.ts +74 -0
  19. package/components/Studio/domain/viroNodeFactory.tsx +175 -44
  20. package/components/Studio/domain/visibilityStore.ts +66 -0
  21. package/components/Studio/index.ts +1 -0
  22. package/components/Studio/types.ts +178 -1
  23. package/components/Utilities/VRModuleOpenXR.ts +35 -0
  24. package/components/Utilities/ViroVersion.ts +1 -1
  25. package/components/ViroAnimatedImage.tsx +1 -0
  26. package/components/ViroFlexView.tsx +1 -0
  27. package/components/ViroImage.tsx +1 -0
  28. package/components/ViroObjectDetector.tsx +230 -0
  29. package/components/ViroParticleEmitter.tsx +2 -0
  30. package/components/ViroPolygon.tsx +2 -1
  31. package/components/ViroQuad.tsx +2 -1
  32. package/components/ViroSurface.tsx +1 -0
  33. package/components/ViroVideo.tsx +1 -0
  34. package/components/ViroXRSceneNavigator.tsx +8 -0
  35. package/dist/components/AR/ViroARPlane.d.ts +1 -1
  36. package/dist/components/AR/ViroARPlane.js +1 -5
  37. package/dist/components/AR/ViroARPlaneSelector.d.ts +1 -1
  38. package/dist/components/AR/ViroARPlaneSelector.js +10 -5
  39. package/dist/components/AR/ViroARScene.d.ts +13 -1
  40. package/dist/components/AR/ViroARScene.js +10 -6
  41. package/dist/components/Studio/StudioARScene.d.ts +3 -0
  42. package/dist/components/Studio/StudioARScene.js +142 -15
  43. package/dist/components/Studio/StudioSceneNavigator.js +14 -0
  44. package/dist/components/Studio/VRTStudioModule.d.ts +6 -0
  45. package/dist/components/Studio/VRTStudioModule.js +10 -0
  46. package/dist/components/Studio/domain/StudioSounds.d.ts +11 -0
  47. package/dist/components/Studio/domain/StudioSounds.js +69 -0
  48. package/dist/components/Studio/domain/apiRequestHelpers.d.ts +180 -0
  49. package/dist/components/Studio/domain/apiRequestHelpers.js +496 -0
  50. package/dist/components/Studio/domain/collisionBindingsRuntime.d.ts +3 -1
  51. package/dist/components/Studio/domain/collisionBindingsRuntime.js +4 -3
  52. package/dist/components/Studio/domain/defaultApiRequestExecutor.d.ts +14 -0
  53. package/dist/components/Studio/domain/defaultApiRequestExecutor.js +58 -0
  54. package/dist/components/Studio/domain/expressionEvaluator.d.ts +108 -0
  55. package/dist/components/Studio/domain/expressionEvaluator.js +520 -0
  56. package/dist/components/Studio/domain/sceneNavigationHandler.d.ts +35 -8
  57. package/dist/components/Studio/domain/sceneNavigationHandler.js +564 -22
  58. package/dist/components/Studio/domain/soundManager.d.ts +52 -0
  59. package/dist/components/Studio/domain/soundManager.js +118 -0
  60. package/dist/components/Studio/domain/utils.d.ts +16 -0
  61. package/dist/components/Studio/domain/utils.js +48 -0
  62. package/dist/components/Studio/domain/variableStore.d.ts +21 -0
  63. package/dist/components/Studio/domain/variableStore.js +65 -0
  64. package/dist/components/Studio/domain/viroNodeFactory.d.ts +4 -9
  65. package/dist/components/Studio/domain/viroNodeFactory.js +84 -25
  66. package/dist/components/Studio/domain/visibilityStore.d.ts +33 -0
  67. package/dist/components/Studio/domain/visibilityStore.js +66 -0
  68. package/dist/components/Studio/index.d.ts +1 -1
  69. package/dist/components/Studio/types.d.ts +150 -1
  70. package/dist/components/Utilities/VRModuleOpenXR.d.ts +19 -0
  71. package/dist/components/Utilities/VRModuleOpenXR.js +16 -0
  72. package/dist/components/Utilities/ViroVersion.d.ts +1 -1
  73. package/dist/components/Utilities/ViroVersion.js +1 -1
  74. package/dist/components/ViroAnimatedImage.js +1 -0
  75. package/dist/components/ViroFlexView.js +1 -0
  76. package/dist/components/ViroImage.js +1 -0
  77. package/dist/components/ViroObjectDetector.d.ts +146 -0
  78. package/dist/components/ViroObjectDetector.js +93 -0
  79. package/dist/components/ViroParticleEmitter.js +2 -0
  80. package/dist/components/ViroPolygon.js +1 -0
  81. package/dist/components/ViroQuad.js +1 -0
  82. package/dist/components/ViroSurface.js +1 -0
  83. package/dist/components/ViroVideo.js +1 -0
  84. package/dist/components/ViroXRSceneNavigator.d.ts +8 -0
  85. package/dist/index.d.ts +6 -4
  86. package/dist/index.js +5 -2
  87. package/dist/plugins/withViro.js +2 -15
  88. package/dist/plugins/withViroAndroid.js +18 -5
  89. package/dist/plugins/withViroIos.js +0 -6
  90. package/index.ts +7 -3
  91. package/ios/ViroReact.podspec +25 -6
  92. package/ios/dist/ViroRenderer/ViroKit.framework/ARCoreCoreMLSemanticsResources.bundle/Info.plist +0 -0
  93. package/ios/dist/ViroRenderer/ViroKit.framework/ARCoreResources.bundle/Info.plist +0 -0
  94. package/ios/dist/ViroRenderer/ViroKit.framework/Headers/VROARFrameiOS.h +9 -0
  95. package/ios/dist/ViroRenderer/ViroKit.framework/Headers/VROARScene.h +14 -1
  96. package/ios/dist/ViroRenderer/ViroKit.framework/Headers/VROARSceneDelegateiOS.h +8 -0
  97. package/ios/dist/ViroRenderer/ViroKit.framework/Headers/VROGLTFLoader.h +5 -1
  98. package/ios/dist/ViroRenderer/ViroKit.framework/Headers/VROMonocularDepthEstimator.h +10 -0
  99. package/ios/dist/ViroRenderer/ViroKit.framework/Headers/VROObjectDetector.h +134 -0
  100. package/ios/dist/ViroRenderer/ViroKit.framework/Info.plist +0 -0
  101. package/ios/dist/ViroRenderer/ViroKit.framework/Shaders.dat +1 -1
  102. package/ios/dist/ViroRenderer/ViroKit.framework/ViroKit +0 -0
  103. package/ios/dist/ViroRendererVisionOS/ViroKit.podspec +27 -0
  104. package/ios/dist/include/VRTARScene.h +1 -0
  105. package/ios/dist/lib/libViroReact.a +0 -0
  106. package/package.json +17 -20
@@ -13,7 +13,7 @@ function pairCooldownKey(pairKey, functionId) {
13
13
  * Cooldown prevents per-frame spam while physics contacts overlap.
14
14
  */
15
15
  function dispatchCollisionBindingActions(params) {
16
- const { selfPlacementId, otherTag, bindingsByPairKey, sceneNavigator, animations, onSceneChange, onAnimationTrigger, cooldownMs = DEFAULT_COOLDOWN_MS, lastFiredRef, } = params;
16
+ const { selfPlacementId, otherTag, bindingsByPairKey, sceneNavigator, animations, onSceneChange, onAnimationTrigger, cooldownMs = DEFAULT_COOLDOWN_MS, lastFiredRef, runtimeCtx, } = params;
17
17
  if (!otherTag)
18
18
  return;
19
19
  const { asset_x_id, asset_y_id } = (0, collisionPairKey_1.canonicalizeCollisionAssetIds)(selfPlacementId, otherTag);
@@ -32,13 +32,13 @@ function dispatchCollisionBindingActions(params) {
32
32
  if (now - last < cooldownMs)
33
33
  continue;
34
34
  map.set(ck, now);
35
- (0, sceneNavigationHandler_1.executeFunctionWithRelations)(fn, sceneNavigator, animations, onAnimationTrigger, 0, onSceneChange);
35
+ (0, sceneNavigationHandler_1.executeFunctionWithRelations)(fn, sceneNavigator, animations, onAnimationTrigger, 0, onSceneChange, runtimeCtx);
36
36
  }
37
37
  }
38
38
  /**
39
39
  * Returns an onCollision handler for a given placement asset ID.
40
40
  */
41
- function createPlacementCollisionHandler(placementId, bindingsByPairKey, sceneNavigator, animations, lastFiredRef, onAnimationTrigger, onSceneChange) {
41
+ function createPlacementCollisionHandler(placementId, bindingsByPairKey, sceneNavigator, animations, lastFiredRef, onAnimationTrigger, onSceneChange, runtimeCtx) {
42
42
  return (viroTag) => {
43
43
  dispatchCollisionBindingActions({
44
44
  selfPlacementId: placementId,
@@ -49,6 +49,7 @@ function createPlacementCollisionHandler(placementId, bindingsByPairKey, sceneNa
49
49
  onSceneChange,
50
50
  onAnimationTrigger,
51
51
  lastFiredRef,
52
+ runtimeCtx,
52
53
  });
53
54
  };
54
55
  }
@@ -0,0 +1,14 @@
1
+ import { StudioApiRequestExecutor } from "../types";
2
+ /**
3
+ * Built-in API_REQUEST transport for production Viro apps: POSTs
4
+ * {function_id, variables} to the scene-api-request egress proxy through the
5
+ * native module, authenticated with the app's RVApiKey (same credential used
6
+ * to fetch scenes). Hosts with their own transport (e.g. StudioGo's JWT
7
+ * controller) override it via runtimeCtx.
8
+ *
9
+ * Always resolves with an outcome — transport-level problems (native module
10
+ * missing, RVApiKey unset, proxy auth/limit errors, malformed envelope)
11
+ * become a NETWORK_ERROR failure so the scene routes to the failure arm
12
+ * instead of crashing.
13
+ */
14
+ export declare const defaultApiRequestExecutor: StudioApiRequestExecutor;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultApiRequestExecutor = void 0;
4
+ const VRTStudioModule_1 = require("../VRTStudioModule");
5
+ /**
6
+ * Built-in API_REQUEST transport for production Viro apps: POSTs
7
+ * {function_id, variables} to the scene-api-request egress proxy through the
8
+ * native module, authenticated with the app's RVApiKey (same credential used
9
+ * to fetch scenes). Hosts with their own transport (e.g. StudioGo's JWT
10
+ * controller) override it via runtimeCtx.
11
+ *
12
+ * Always resolves with an outcome — transport-level problems (native module
13
+ * missing, RVApiKey unset, proxy auth/limit errors, malformed envelope)
14
+ * become a NETWORK_ERROR failure so the scene routes to the failure arm
15
+ * instead of crashing.
16
+ */
17
+ const defaultApiRequestExecutor = async (functionId, variables) => {
18
+ const result = await VRTStudioModule_1.VRTStudioModule.rvStudioApiRequest(JSON.stringify({ function_id: functionId, variables }));
19
+ if (!result.success || typeof result.data !== "string") {
20
+ return failureOutcome(extractErrorMessage(result.error));
21
+ }
22
+ try {
23
+ const envelope = JSON.parse(result.data);
24
+ return {
25
+ ok: envelope.ok === true,
26
+ status: typeof envelope.status === "number" ? envelope.status : null,
27
+ body: envelope.body,
28
+ error_code: envelope.error_code ?? null,
29
+ error_message: envelope.error_message ?? null,
30
+ };
31
+ }
32
+ catch {
33
+ return failureOutcome("Malformed scene-api-request response");
34
+ }
35
+ };
36
+ exports.defaultApiRequestExecutor = defaultApiRequestExecutor;
37
+ function failureOutcome(message) {
38
+ return {
39
+ ok: false,
40
+ status: null,
41
+ error_code: "NETWORK_ERROR",
42
+ error_message: message,
43
+ };
44
+ }
45
+ /** Proxy auth/contract errors arrive as {"error":{"code","message"}} JSON. */
46
+ function extractErrorMessage(error) {
47
+ if (!error)
48
+ return "Request failed";
49
+ try {
50
+ const parsed = JSON.parse(error);
51
+ if (typeof parsed.error?.message === "string")
52
+ return parsed.error.message;
53
+ }
54
+ catch {
55
+ // not JSON — use the raw transport error
56
+ }
57
+ return error;
58
+ }
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Studio expression evaluator: parses and evaluates the literal-or-expression
3
+ * values written by SET_VARIABLE steps (and, later, reused by Branch
4
+ * conditions via compare()). Hand-rolled tokenizer + recursive descent over a
5
+ * fixed grammar — never eval()/Function().
6
+ *
7
+ * Dual-maintained: this file exists in the Viro repo
8
+ * (components/Studio/domain/) and the ReactVisionStudio monorepo
9
+ * (packages/common/scene-assets/). Keep the two copies identical.
10
+ *
11
+ * Grammar (precedence low → high):
12
+ * or := and ( "||" and )* Boolean operands
13
+ * and := equality ( "&&" equality )* Boolean operands
14
+ * equality := relational ( ("=="|"!=") relational )* same-type operands
15
+ * relational := additive ( ("<"|"<="|">"|">=") additive )* Number only
16
+ * additive := multiplicative ( ("+"|"-") multiplicative )*
17
+ * "+" adds Numbers, or concatenates if either side is a String
18
+ * multiplicative := unary ( ("*"|"/") unary )* Number only
19
+ * unary := ("!"|"-") unary | primary
20
+ * primary := NUMBER | STRING | "true" | "false" | IDENT | "(" or ")"
21
+ */
22
+ export type StudioVariableType = "BOOLEAN" | "NUMBER" | "STRING";
23
+ export type StudioVariableValue = boolean | number | string;
24
+ export declare const MAX_EXPRESSION_LENGTH = 500;
25
+ export declare const VARIABLE_NAME_PATTERN: RegExp;
26
+ type BinaryOp = "||" | "&&" | "==" | "!=" | "<" | "<=" | ">" | ">=" | "+" | "-" | "*" | "/";
27
+ type UnaryOp = "!" | "-";
28
+ export type ExpressionNode = {
29
+ kind: "literal";
30
+ value: StudioVariableValue;
31
+ } | {
32
+ kind: "variable";
33
+ name: string;
34
+ } | {
35
+ kind: "unary";
36
+ op: UnaryOp;
37
+ operand: ExpressionNode;
38
+ } | {
39
+ kind: "binary";
40
+ op: BinaryOp;
41
+ left: ExpressionNode;
42
+ right: ExpressionNode;
43
+ };
44
+ export type ParseResult = {
45
+ ok: true;
46
+ ast: ExpressionNode;
47
+ refs: string[];
48
+ } | {
49
+ ok: false;
50
+ error: string;
51
+ };
52
+ export type TypeCheckResult = {
53
+ ok: true;
54
+ type: StudioVariableType;
55
+ } | {
56
+ ok: false;
57
+ error: string;
58
+ };
59
+ export type EvaluateResult = {
60
+ ok: true;
61
+ value: StudioVariableValue;
62
+ } | {
63
+ ok: false;
64
+ error: string;
65
+ };
66
+ export declare function parseExpression(src: string): ParseResult;
67
+ export declare function checkTypes(node: ExpressionNode, declared: Record<string, StudioVariableType>): TypeCheckResult;
68
+ /** Parse + type-check an expression against a target variable's type in one call. */
69
+ export declare function validateExpressionForTarget(src: string, targetType: StudioVariableType, declared: Record<string, StudioVariableType>): {
70
+ ok: true;
71
+ } | {
72
+ ok: false;
73
+ error: string;
74
+ };
75
+ export type ComparisonOp = "==" | "!=" | "<" | "<=" | ">" | ">=";
76
+ /** Typed comparison shared with Branch conditions. Throws on operand mismatch. */
77
+ export declare function compare(op: ComparisonOp, left: StudioVariableValue, right: StudioVariableValue): boolean;
78
+ export type BranchComparison = "EQUALS" | "NOT_EQUALS" | "GREATER_THAN" | "LESS_THAN" | "GREATER_OR_EQUAL" | "LESS_OR_EQUAL" | "LIKE" | "ILIKE";
79
+ /** Structural input so this file stays standalone (no scene-type imports). */
80
+ export type BranchConditionInput = {
81
+ comparison: BranchComparison;
82
+ variable_name: string;
83
+ compare_literal: StudioVariableValue | null;
84
+ compare_variable_name: string | null;
85
+ };
86
+ export type BranchConditionResult = {
87
+ ok: true;
88
+ value: boolean;
89
+ } | {
90
+ ok: false;
91
+ error: string;
92
+ };
93
+ /**
94
+ * Evaluates a structured Branch condition against the runtime store.
95
+ * Never throws; callers warn + skip both arms on { ok: false }.
96
+ */
97
+ export declare function evaluateBranchCondition(cond: BranchConditionInput, get: (name: string) => StudioVariableValue | undefined): BranchConditionResult;
98
+ export declare function evaluate(node: ExpressionNode, get: (name: string) => StudioVariableValue | undefined): EvaluateResult;
99
+ export declare function valueMatchesType(value: StudioVariableValue, type: StudioVariableType): boolean;
100
+ /** Serialize a literal value into expression syntax (the editor's literal mode). */
101
+ export declare function formatLiteral(value: StudioVariableValue): string;
102
+ /**
103
+ * Rewrite every reference to oldName in an expression's source, preserving all
104
+ * other formatting (token-span splicing). Returns the source unchanged if it
105
+ * does not tokenize. Powers variable rename in the editor.
106
+ */
107
+ export declare function renameIdentifier(src: string, oldName: string, newName: string): string;
108
+ export {};