@buoy-gg/license 1.7.8 → 2.1.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 (47) hide show
  1. package/lib/commonjs/DeviceRegistrationModal.js +189 -0
  2. package/lib/commonjs/LicenseManager.js +269 -545
  3. package/lib/commonjs/api.js +47 -73
  4. package/lib/commonjs/config.js +5 -3
  5. package/lib/commonjs/hooks.js +10 -137
  6. package/lib/commonjs/index.js +11 -36
  7. package/lib/commonjs/index.web.js +6 -39
  8. package/lib/module/DeviceRegistrationModal.js +185 -0
  9. package/lib/module/LicenseManager.js +271 -547
  10. package/lib/module/api.js +47 -69
  11. package/lib/module/config.js +5 -3
  12. package/lib/module/hooks.js +11 -136
  13. package/lib/module/index.js +7 -4
  14. package/lib/module/index.web.js +6 -5
  15. package/lib/typescript/commonjs/DeviceRegistrationModal.d.ts +19 -0
  16. package/lib/typescript/commonjs/DeviceRegistrationModal.d.ts.map +1 -0
  17. package/lib/typescript/commonjs/LicenseManager.d.ts +33 -66
  18. package/lib/typescript/commonjs/LicenseManager.d.ts.map +1 -1
  19. package/lib/typescript/commonjs/api.d.ts +6 -19
  20. package/lib/typescript/commonjs/api.d.ts.map +1 -1
  21. package/lib/typescript/commonjs/config.d.ts +1 -1
  22. package/lib/typescript/commonjs/config.d.ts.map +1 -1
  23. package/lib/typescript/commonjs/hooks.d.ts +5 -33
  24. package/lib/typescript/commonjs/hooks.d.ts.map +1 -1
  25. package/lib/typescript/commonjs/index.d.ts +9 -4
  26. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  27. package/lib/typescript/commonjs/index.web.d.ts +8 -5
  28. package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
  29. package/lib/typescript/commonjs/types.d.ts +17 -59
  30. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  31. package/lib/typescript/module/DeviceRegistrationModal.d.ts +19 -0
  32. package/lib/typescript/module/DeviceRegistrationModal.d.ts.map +1 -0
  33. package/lib/typescript/module/LicenseManager.d.ts +33 -66
  34. package/lib/typescript/module/LicenseManager.d.ts.map +1 -1
  35. package/lib/typescript/module/api.d.ts +6 -19
  36. package/lib/typescript/module/api.d.ts.map +1 -1
  37. package/lib/typescript/module/config.d.ts +1 -1
  38. package/lib/typescript/module/config.d.ts.map +1 -1
  39. package/lib/typescript/module/hooks.d.ts +5 -33
  40. package/lib/typescript/module/hooks.d.ts.map +1 -1
  41. package/lib/typescript/module/index.d.ts +9 -4
  42. package/lib/typescript/module/index.d.ts.map +1 -1
  43. package/lib/typescript/module/index.web.d.ts +8 -5
  44. package/lib/typescript/module/index.web.d.ts.map +1 -1
  45. package/lib/typescript/module/types.d.ts +17 -59
  46. package/lib/typescript/module/types.d.ts.map +1 -1
  47. package/package.json +1 -1
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DeviceRegistrationModal = DeviceRegistrationModal;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _LicenseManager = require("./LicenseManager.js");
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
+ /**
13
+ * DeviceRegistrationModal - Prompts user to name their device during first registration
14
+ *
15
+ * Styled to match the Buoy brand design system.
16
+ */
17
+
18
+ // Buoy brand colors - matches shared/src/ui/gameUI/constants/gameUIColors.ts
19
+ const buoyColors = {
20
+ base: "#121212",
21
+ card: "#1A1A1A",
22
+ hover: "#242424",
23
+ input: "#2A2A2A",
24
+ border: "#333333",
25
+ borderStrong: "#444444",
26
+ text: "#E0E0E0",
27
+ textSecondary: "#A0A0A0",
28
+ textMuted: "#888888",
29
+ primary: "#20C997",
30
+ // Buoy teal
31
+ success: "#20C997",
32
+ warning: "#FFA94D",
33
+ error: "#EF4444",
34
+ info: "#00B8E6"
35
+ };
36
+ function DeviceRegistrationModal({
37
+ title = "Name Your Device",
38
+ description = "Give this device a name to help you identify it later.",
39
+ buttonText = "Continue",
40
+ onComplete
41
+ }) {
42
+ const [visible, setVisible] = (0, _react.useState)(false);
43
+ const [deviceName, setDeviceName] = (0, _react.useState)("");
44
+ const [defaultName, setDefaultName] = (0, _react.useState)("");
45
+ const [isRegistering, setIsRegistering] = (0, _react.useState)(false);
46
+ (0, _react.useEffect)(() => {
47
+ // Subscribe to device registration requests
48
+ const unsubscribe = _LicenseManager.LicenseManager.onDeviceRegistrationNeeded(info => {
49
+ setDefaultName(info.defaultName);
50
+ setDeviceName(info.defaultName);
51
+ setVisible(true);
52
+ });
53
+ return unsubscribe;
54
+ }, []);
55
+ const handleSubmit = (0, _react.useCallback)(async () => {
56
+ const name = deviceName.trim() || defaultName;
57
+ setIsRegistering(true);
58
+ try {
59
+ await _LicenseManager.LicenseManager.completeDeviceRegistration(name);
60
+ setVisible(false);
61
+ onComplete?.(name);
62
+ } catch (error) {
63
+ console.warn("[Buoy] Device registration failed:", error);
64
+ // Still close the modal - registration failure shouldn't block the user
65
+ setVisible(false);
66
+ } finally {
67
+ setIsRegistering(false);
68
+ }
69
+ }, [deviceName, defaultName, onComplete]);
70
+ if (!visible) return null;
71
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Modal, {
72
+ visible: visible,
73
+ transparent: true,
74
+ animationType: "fade",
75
+ onRequestClose: () => {
76
+ // Allow closing without naming - use default
77
+ handleSubmit();
78
+ },
79
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.KeyboardAvoidingView, {
80
+ behavior: _reactNative.Platform.OS === "ios" ? "padding" : "height",
81
+ style: styles.overlay,
82
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
83
+ style: styles.container,
84
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
85
+ style: styles.accentBar
86
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
87
+ style: styles.content,
88
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
89
+ style: styles.title,
90
+ children: title
91
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
92
+ style: styles.description,
93
+ children: description
94
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TextInput, {
95
+ style: styles.input,
96
+ value: deviceName,
97
+ onChangeText: setDeviceName,
98
+ placeholder: defaultName,
99
+ placeholderTextColor: buoyColors.textMuted,
100
+ autoFocus: true,
101
+ returnKeyType: "done",
102
+ onSubmitEditing: handleSubmit,
103
+ editable: !isRegistering,
104
+ selectionColor: buoyColors.primary
105
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
106
+ style: [styles.button, isRegistering && styles.buttonDisabled],
107
+ onPress: handleSubmit,
108
+ disabled: isRegistering,
109
+ activeOpacity: 0.8,
110
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
111
+ style: styles.buttonText,
112
+ children: isRegistering ? "Registering..." : buttonText
113
+ })
114
+ })]
115
+ })]
116
+ })
117
+ })
118
+ });
119
+ }
120
+ const styles = _reactNative.StyleSheet.create({
121
+ overlay: {
122
+ flex: 1,
123
+ backgroundColor: "rgba(0, 0, 0, 0.75)",
124
+ justifyContent: "center",
125
+ alignItems: "center"
126
+ },
127
+ container: {
128
+ backgroundColor: buoyColors.card,
129
+ borderRadius: 12,
130
+ width: "85%",
131
+ maxWidth: 400,
132
+ borderWidth: 1,
133
+ borderColor: buoyColors.border,
134
+ shadowColor: buoyColors.primary,
135
+ shadowOffset: {
136
+ width: 0,
137
+ height: 0
138
+ },
139
+ shadowOpacity: 0.2,
140
+ shadowRadius: 20,
141
+ elevation: 20,
142
+ overflow: "hidden"
143
+ },
144
+ accentBar: {
145
+ height: 3,
146
+ backgroundColor: buoyColors.primary
147
+ },
148
+ content: {
149
+ padding: 24
150
+ },
151
+ title: {
152
+ fontSize: 20,
153
+ fontWeight: "600",
154
+ color: buoyColors.text,
155
+ marginBottom: 8,
156
+ textAlign: "center"
157
+ },
158
+ description: {
159
+ fontSize: 14,
160
+ color: buoyColors.textSecondary,
161
+ marginBottom: 24,
162
+ textAlign: "center",
163
+ lineHeight: 20
164
+ },
165
+ input: {
166
+ borderWidth: 1,
167
+ borderColor: buoyColors.border,
168
+ borderRadius: 8,
169
+ padding: 14,
170
+ fontSize: 16,
171
+ color: buoyColors.text,
172
+ backgroundColor: buoyColors.input,
173
+ marginBottom: 20
174
+ },
175
+ button: {
176
+ backgroundColor: buoyColors.primary,
177
+ borderRadius: 8,
178
+ padding: 14,
179
+ alignItems: "center"
180
+ },
181
+ buttonDisabled: {
182
+ backgroundColor: buoyColors.textMuted
183
+ },
184
+ buttonText: {
185
+ color: buoyColors.base,
186
+ fontSize: 16,
187
+ fontWeight: "600"
188
+ }
189
+ });