com.amanotes.gdk 0.2.46 → 0.2.48

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 (78) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/Editor/AmaGDKEditor.cs +281 -104
  3. package/Editor/MatchSDKVersion.cs +3 -6
  4. package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +5 -1
  5. package/Extra/AmaGDKInstaller.unitypackage +0 -0
  6. package/Extra/AmaGDKProject.unitypackage +0 -0
  7. package/Packages/AmaGDKConfig.unitypackage +0 -0
  8. package/Packages/AmaGDKExample.unitypackage +0 -0
  9. package/Packages/AmaGDKTest.unitypackage +0 -0
  10. package/Packages/AppsFlyerAdapter.unitypackage +0 -0
  11. package/Packages/{FirebaseRemoteConfigAdapter_v9.1.0.unitypackage.meta → AppsFlyerAdapter.unitypackage.meta} +1 -1
  12. package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
  13. package/Packages/{AppsFlyerAdapter_v6.5.4.unitypackage.meta → FirebaseAnalyticsAdapter.unitypackage.meta} +1 -1
  14. package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
  15. package/Packages/{IronSourceAdapter_v7.5.2.unitypackage.meta → FirebaseRemoteConfigAdapter.unitypackage.meta} +1 -1
  16. package/Packages/IronSourceAdapter.unitypackage +0 -0
  17. package/Packages/{FirebaseAnalyticsAdapter_v9.1.0.unitypackage.meta → IronSourceAdapter.unitypackage.meta} +1 -1
  18. package/Packages/RevenueCatAdapter.unitypackage +0 -0
  19. package/Packages/RevenueCatAdapter.unitypackage.meta +7 -0
  20. package/Runtime/AmaGDK.Adapters.cs +55 -77
  21. package/Runtime/AmaGDK.Ads.cs +160 -174
  22. package/Runtime/AmaGDK.Analytics.cs +245 -125
  23. package/Runtime/AmaGDK.Config.cs +2 -1
  24. package/Runtime/AmaGDK.IAP.cs +47 -48
  25. package/Runtime/AmaGDK.RemoteConfig.cs +38 -35
  26. package/Runtime/AmaGDK.UserProfile.cs +27 -19
  27. package/Runtime/AmaGDK.cs +158 -111
  28. package/Runtime/Internal/AmaGDK.Internal.AmaGUI.cs +8 -3
  29. package/Runtime/Internal/AmaGDK.Internal.SemVer.cs +21 -17
  30. package/Runtime/Internal/AmaGDK.Internal.cs +17 -6
  31. package/Runtime/Internal/AmaGDK.Utils.cs +78 -11
  32. package/Runtime/Klavar/Attributes/AccumulatedCountAttribute.cs +19 -0
  33. package/Runtime/Klavar/Attributes/AccumulatedCountAttribute.cs.meta +11 -0
  34. package/Runtime/Klavar/Attributes/ConnectionAttribute.cs +18 -0
  35. package/Runtime/Klavar/Attributes/ConnectionAttribute.cs.meta +11 -0
  36. package/Runtime/Klavar/Attributes/CountInSessionAttribute.cs +27 -0
  37. package/Runtime/Klavar/Attributes/CountInSessionAttribute.cs.meta +11 -0
  38. package/Runtime/Klavar/Attributes/DescriptionAttribute.cs +7 -0
  39. package/Runtime/Klavar/Attributes/DescriptionAttribute.cs.meta +11 -0
  40. package/Runtime/Klavar/Attributes/DynamicValidateAttribute.cs +30 -0
  41. package/Runtime/Klavar/Attributes/DynamicValidateAttribute.cs.meta +11 -0
  42. package/Runtime/Klavar/Attributes/IgnoreAttribute.cs +16 -0
  43. package/Runtime/Klavar/Attributes/IgnoreAttribute.cs.meta +11 -0
  44. package/Runtime/Klavar/Attributes/MinMaxAttribute.cs +130 -0
  45. package/Runtime/Klavar/Attributes/MinMaxAttribute.cs.meta +11 -0
  46. package/Runtime/Klavar/Attributes/MinMaxLengthAttribute.cs +88 -0
  47. package/Runtime/Klavar/Attributes/MinMaxLengthAttribute.cs.meta +11 -0
  48. package/Runtime/Klavar/Attributes/NameAttribute.cs +35 -0
  49. package/Runtime/Klavar/Attributes/NameAttribute.cs.meta +11 -0
  50. package/Runtime/Klavar/Attributes/NotNullAttribute.cs +16 -0
  51. package/Runtime/Klavar/Attributes/NotNullAttribute.cs.meta +11 -0
  52. package/Runtime/Klavar/Attributes/RegexPatternAttribute.cs +58 -0
  53. package/Runtime/Klavar/Attributes/RegexPatternAttribute.cs.meta +11 -0
  54. package/Runtime/Klavar/Attributes/TimeDiffLastFireAttribute.cs +28 -0
  55. package/Runtime/Klavar/Attributes/TimeDiffLastFireAttribute.cs.meta +11 -0
  56. package/Runtime/Klavar/Attributes/ToStringAttribute.cs +97 -0
  57. package/Runtime/Klavar/Attributes/ToStringAttribute.cs.meta +11 -0
  58. package/Runtime/Klavar/Attributes/ValueAttribute.cs +30 -0
  59. package/Runtime/Klavar/Attributes/ValueAttribute.cs.meta +11 -0
  60. package/Runtime/Klavar/Attributes.meta +12 -0
  61. package/Runtime/Klavar/KlavarEvent.cs +91 -0
  62. package/Runtime/Klavar/KlavarEvent.cs.meta +11 -0
  63. package/Runtime/Klavar/KlavarEventAttribute.cs +39 -0
  64. package/Runtime/Klavar/KlavarEventAttribute.cs.meta +11 -0
  65. package/Runtime/Klavar/KlavarEventTools.cs +92 -0
  66. package/Runtime/Klavar/KlavarEventTools.cs.meta +11 -0
  67. package/Runtime/Klavar/KlavarEventUtils.cs +58 -0
  68. package/Runtime/Klavar/KlavarEventUtils.cs.meta +11 -0
  69. package/Runtime/Klavar.meta +12 -0
  70. package/package.json +1 -1
  71. package/Packages/AppsFlyerAdapter_v6.5.4.unitypackage +0 -0
  72. package/Packages/FirebaseAnalyticsAdapter_v9.1.0.unitypackage +0 -0
  73. package/Packages/FirebaseRemoteConfigAdapter_v9.1.0.unitypackage +0 -0
  74. package/Packages/IronSourceAdapter_v7.5.2.unitypackage +0 -0
  75. package/Packages/IronsourceAdapter_v7.2.6.unitypackage +0 -0
  76. package/Packages/IronsourceAdapter_v7.2.6.unitypackage.meta +0 -7
  77. package/Packages/RevenueCatAdapter_v6.0.0.unitypackage +0 -0
  78. package/Packages/RevenueCatAdapter_v6.0.0.unitypackage.meta +0 -7
@@ -6,109 +6,87 @@ using static Amanotes.Core.Internal.Logging;
6
6
 
7
7
  namespace Amanotes.Core.Internal
8
8
  {
9
- public abstract class AdapterContext
9
+ public abstract partial class Adapter2
10
10
  {
11
- public string adapterId;
12
- public string adapterVersion;
13
- public int initOrder;
14
- public GameObject refObj;
15
-
16
- // Status support
17
- public Status status = Status.None;
11
+ // internal use
12
+ [HideInInspector] [SerializeField] internal int initOrder;
13
+ [HideInInspector] [SerializeField] internal bool enabled = true;
14
+ [NonSerialized] internal string adapterId;
15
+ [NonSerialized] internal string adapterVersion;
16
+ [NonSerialized] internal protected Status status = Status.None;
17
+
18
+ protected abstract void Init(Action<bool> onComplete);
19
+
18
20
  public bool IsReady => status == Status.Ready;
19
-
20
- public void Init()
21
+
22
+ internal void InitSDK() // call by AmaGDK
21
23
  {
22
24
  if (status != Status.None)
23
25
  {
24
- LogWarning($"Invalid status: {status}");
26
+ LogWarning($"InitSDK() - Invalid Adapter <{adapterId}> status (expect <None>, got: <{status}>)");
25
27
  return;
26
28
  }
27
-
29
+
30
+ #if UNITY_EDITOR
31
+ status = Status.Ready;
32
+ #else
28
33
  status = Status.Initialize;
29
34
  Init(success =>
30
35
  {
31
36
  status = success ? Status.Ready : Status.Failed;
32
37
  });
38
+ #endif
33
39
  }
34
-
35
- protected virtual void Init(Action<bool> onCompleted) { }
36
- public T GetAdapterApi<T>() { return (T)(object)this; }
37
- public abstract T GetAdapterConfig<T>() where T : class;
38
40
  }
39
-
40
- public static class Adapter
41
+
42
+ public abstract partial class Adapter2
41
43
  {
42
- internal static readonly List<AdapterContext> listAdapters = new List<AdapterContext>();
43
-
44
- public static string GetId(Type adapterType)
44
+ [NonSerialized] internal static readonly Dictionary<string, Adapter2> adapterMap = new Dictionary<string, Adapter2>();
45
+ protected static bool Register(string id, string version)
45
46
  {
46
- return adapterType.Name.Replace("Adapter", string.Empty);
47
- }
48
-
49
- public static void Register<T>(Func<ConfigAsset, T> createFunc) where T : AdapterContext
50
- {
51
- if (AmaGDK._status != Status.None)
47
+ if (adapterMap.ContainsKey(id))
52
48
  {
53
- LogWarningOnce($"RegisterAdapter - Invalid status: {AmaGDK._status}");
54
- return;
49
+ LogWarning($"Duplicated Adapter id registered <{id}>");
50
+ return false;
55
51
  }
56
-
57
- T adapter = createFunc(AmaGDK.Config);
58
- InitOrder orderConfig = AmaGDK.Config.initOrder.FirstOrDefault(item => item.id == adapter.adapterId);
59
- if (orderConfig != null) adapter.initOrder = orderConfig.order;
60
- listAdapters.Add(adapter);
61
- }
62
-
63
- public static AdapterContext Find<T>()
64
- {
65
- for (var i = 0; i < listAdapters.Count; i++)
52
+
53
+ var adapter = AmaGDK.Config.GetFieldValue<Adapter2>(id);
54
+ if (adapter == null)
66
55
  {
67
- AdapterContext item = listAdapters[i];
68
- Type itemType = item.GetType();
69
- if (!typeof(T).IsAssignableFrom(itemType)) continue;
70
- return item;
56
+ LogWarning($"Adapter <{id}> == null in ConfigAsset? (non-serialized?)");
57
+ return false;
71
58
  }
72
-
73
- return default;
59
+
60
+ adapter.adapterId = id;
61
+ adapter.adapterVersion = version;
62
+ GDKUtils.RegisterUnityCallbacks(adapter);
63
+ adapterMap.Add(id, adapter);
64
+ return true;
74
65
  }
75
-
76
- public static List<AdapterContext> FindAll<T>()
66
+
67
+ // PUBLIC STATIC APIs
68
+ public static Adapter2 GetAdapterById(string id)
77
69
  {
78
- var result = new List<AdapterContext>();
79
- for (var i = 0; i < listAdapters.Count; i++)
80
- {
81
- AdapterContext item = listAdapters[i];
82
- Type itemType = item.GetType();
83
- if (!typeof(T).IsAssignableFrom(itemType)) continue;
84
- result.Add(item);
85
- }
86
-
87
- return result;
70
+ return GetAdapterById<Adapter2>(id);
88
71
  }
89
-
90
- public static T GetSingleAdapter<T>() where T : class
72
+ public static TAdapter GetAdapterById<TAdapter>(string id) where TAdapter: Adapter2
91
73
  {
92
- List<AdapterContext> adapters = FindAll<T>();
93
-
94
- if (adapters == null || adapters.Count < 1)
95
- {
96
- Log($"Not found adapter for <{typeof(T)}>!");
97
- return null;
98
- }
99
-
100
- if (adapters.Count > 1)
101
- {
102
- LogError($"Multiple adapters detected. <{typeof(T)}> supports only one adapter!");
103
- return null;
104
- }
105
-
106
- return adapters[0].GetAdapterApi<T>();
74
+ return adapterMap.TryGetValue(id, out var result) ? (TAdapter)result : null;
107
75
  }
108
-
109
- public static T GetConfig<T>() where T : ConfigAsset
76
+
77
+ public static TAdapter GetAdapter<TAdapter>() where TAdapter: Adapter2
78
+ {
79
+ var result = adapterMap.Values
80
+ .FirstOrDefault(value => value is TAdapter);
81
+
82
+ return (TAdapter)result;
83
+ }
84
+
85
+ public static List<TAdapter> GetAllAdapter<TAdapter>() where TAdapter: Adapter2
110
86
  {
111
- return (T)AmaGDK.Config;
87
+ return adapterMap.Values
88
+ .OfType<TAdapter>()
89
+ .ToList();
112
90
  }
113
91
  }
114
92
  }