JSValue GlobalObject::requireBuiltinModule(const JSContext& js_context, const std::string& moduleId) { if (moduleId == "ti.map") { JSValue Titanium_property = js_context.get_global_object().GetProperty("Titanium"); TITANIUM_ASSERT(Titanium_property.IsObject()); // precondition JSObject Titanium = static_cast<JSObject>(Titanium_property); JSValue Map_property = Titanium.GetProperty("Map"); TITANIUM_ASSERT(Map_property.IsObject()); // precondition return Map_property; } return js_context.CreateUndefined(); }
bool Analytics::loadJS() { if (ti_analytics__.HasProperty("lastEvent") && ti_analytics__.HasProperty("featureEvent") && ti_analytics__.HasProperty("navEvent")) { return true; } JSContext context = get_context(); auto export_object = context.CreateObject(); export_object.SetProperty("global", context.get_global_object()); context.JSEvaluateScript(analytics_js, export_object); if (export_object.HasProperty("exports")) { ti_analytics__ = static_cast<JSObject>(export_object.GetProperty("exports")); } else { return false; } return true; }