@cond/simasdk 0.0.0-stage → 0.1.0

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 (70) hide show
  1. package/CondSimasdk.podspec +18 -0
  2. package/Package.swift +29 -0
  3. package/README.md +508 -2
  4. package/android/build.gradle +61 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/com/simasdk/SimaFirebasePlugin.java +139 -0
  7. package/android/src/main/java/com/simasdk/SimaHapticsPlugin.java +101 -0
  8. package/android/src/main/java/com/simasdk/SimaReviewPlugin.java +48 -0
  9. package/android/src/main/java/com/simasdk/SimaStoragePlugin.java +79 -0
  10. package/dist/ads.cjs +214 -0
  11. package/dist/ads.cjs.map +1 -0
  12. package/dist/ads.d.cts +98 -0
  13. package/dist/ads.d.ts +98 -0
  14. package/dist/ads.js +211 -0
  15. package/dist/ads.js.map +1 -0
  16. package/dist/back-button.cjs +95 -0
  17. package/dist/back-button.cjs.map +1 -0
  18. package/dist/back-button.d.cts +45 -0
  19. package/dist/back-button.d.ts +45 -0
  20. package/dist/back-button.js +88 -0
  21. package/dist/back-button.js.map +1 -0
  22. package/dist/cli.js +662 -0
  23. package/dist/firebase.cjs +102 -0
  24. package/dist/firebase.cjs.map +1 -0
  25. package/dist/firebase.d.cts +40 -0
  26. package/dist/firebase.d.ts +40 -0
  27. package/dist/firebase.js +99 -0
  28. package/dist/firebase.js.map +1 -0
  29. package/dist/haptics.cjs +81 -0
  30. package/dist/haptics.cjs.map +1 -0
  31. package/dist/haptics.d.cts +51 -0
  32. package/dist/haptics.d.ts +51 -0
  33. package/dist/haptics.js +78 -0
  34. package/dist/haptics.js.map +1 -0
  35. package/dist/index.cjs +233 -0
  36. package/dist/index.cjs.map +1 -0
  37. package/dist/index.d.cts +99 -0
  38. package/dist/index.d.ts +99 -0
  39. package/dist/index.js +226 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/react.cjs +118 -0
  42. package/dist/react.cjs.map +1 -0
  43. package/dist/react.d.cts +51 -0
  44. package/dist/react.d.ts +51 -0
  45. package/dist/react.js +113 -0
  46. package/dist/react.js.map +1 -0
  47. package/dist/review.cjs +195 -0
  48. package/dist/review.cjs.map +1 -0
  49. package/dist/review.d.cts +76 -0
  50. package/dist/review.d.ts +76 -0
  51. package/dist/review.js +192 -0
  52. package/dist/review.js.map +1 -0
  53. package/dist/shell.cjs +97 -0
  54. package/dist/shell.cjs.map +1 -0
  55. package/dist/shell.d.cts +36 -0
  56. package/dist/shell.d.ts +36 -0
  57. package/dist/shell.js +91 -0
  58. package/dist/shell.js.map +1 -0
  59. package/dist/storage.cjs +140 -0
  60. package/dist/storage.cjs.map +1 -0
  61. package/dist/storage.d.cts +48 -0
  62. package/dist/storage.d.ts +48 -0
  63. package/dist/storage.js +136 -0
  64. package/dist/storage.js.map +1 -0
  65. package/ios/Sources/SimasdkPlugin/SimaFirebasePlugin.swift +188 -0
  66. package/ios/Sources/SimasdkPlugin/SimaHapticsPlugin.swift +61 -0
  67. package/ios/Sources/SimasdkPlugin/SimaReviewPlugin.swift +40 -0
  68. package/ios/Sources/SimasdkPlugin/SimaStoragePlugin.swift +58 -0
  69. package/package.json +118 -4
  70. package/skills/simasdk/SKILL.md +189 -0
package/dist/shell.cjs ADDED
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ // src/shell.ts
6
+ var StatusBarPlugin = core.registerPlugin("StatusBar");
7
+ var SplashScreenPlugin = core.registerPlugin("SplashScreen");
8
+ var ScreenOrientationPlugin = core.registerPlugin("ScreenOrientation");
9
+ function isNative() {
10
+ return typeof window !== "undefined" && core.Capacitor.isNativePlatform();
11
+ }
12
+ async function setStatusBar(options) {
13
+ if (!isNative() || !core.Capacitor.isPluginAvailable("StatusBar")) {
14
+ return false;
15
+ }
16
+ try {
17
+ if (options.style) {
18
+ const mapped = options.style === "dark" ? "DARK" : options.style === "light" ? "LIGHT" : "DEFAULT";
19
+ await StatusBarPlugin.setStyle({ style: mapped });
20
+ }
21
+ if (typeof options.overlay === "boolean") {
22
+ await StatusBarPlugin.setOverlaysWebView({ overlay: options.overlay });
23
+ }
24
+ if (options.backgroundColor && core.Capacitor.getPlatform() === "android") {
25
+ await StatusBarPlugin.setBackgroundColor({ color: options.backgroundColor });
26
+ }
27
+ return true;
28
+ } catch {
29
+ return false;
30
+ }
31
+ }
32
+ async function hideSplashScreen() {
33
+ if (!isNative() || !core.Capacitor.isPluginAvailable("SplashScreen")) {
34
+ return false;
35
+ }
36
+ try {
37
+ await SplashScreenPlugin.hide();
38
+ return true;
39
+ } catch {
40
+ return false;
41
+ }
42
+ }
43
+ async function lockOrientation(orientation) {
44
+ if (!isNative() || !core.Capacitor.isPluginAvailable("ScreenOrientation")) {
45
+ return false;
46
+ }
47
+ try {
48
+ await ScreenOrientationPlugin.lock({ orientation });
49
+ return true;
50
+ } catch {
51
+ return false;
52
+ }
53
+ }
54
+ async function unlockOrientation() {
55
+ if (!isNative() || !core.Capacitor.isPluginAvailable("ScreenOrientation")) {
56
+ return false;
57
+ }
58
+ try {
59
+ await ScreenOrientationPlugin.unlock();
60
+ return true;
61
+ } catch {
62
+ return false;
63
+ }
64
+ }
65
+ async function initShell(config = {}) {
66
+ if (!isNative()) {
67
+ return {
68
+ platform: "web",
69
+ statusBarApplied: false,
70
+ splashHidden: false,
71
+ orientationLocked: false
72
+ };
73
+ }
74
+ const [statusBarApplied, orientationLocked, splashHidden] = await Promise.all([
75
+ config.statusBarStyle || config.statusBarBackgroundColor || typeof config.statusBarOverlay === "boolean" ? setStatusBar({
76
+ style: config.statusBarStyle,
77
+ backgroundColor: config.statusBarBackgroundColor,
78
+ overlay: config.statusBarOverlay
79
+ }) : Promise.resolve(false),
80
+ config.orientation ? lockOrientation(config.orientation) : Promise.resolve(false),
81
+ config.hideSplash ? hideSplashScreen() : Promise.resolve(false)
82
+ ]);
83
+ return {
84
+ platform: "native",
85
+ statusBarApplied,
86
+ splashHidden,
87
+ orientationLocked
88
+ };
89
+ }
90
+
91
+ exports.hideSplashScreen = hideSplashScreen;
92
+ exports.initShell = initShell;
93
+ exports.lockOrientation = lockOrientation;
94
+ exports.setStatusBar = setStatusBar;
95
+ exports.unlockOrientation = unlockOrientation;
96
+ //# sourceMappingURL=shell.cjs.map
97
+ //# sourceMappingURL=shell.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/shell.ts"],"names":["registerPlugin","Capacitor"],"mappings":";;;;;AAwCA,IAAM,eAAA,GAAkBA,oBAA8B,WAAW,CAAA;AACjE,IAAM,kBAAA,GAAqBA,oBAAiC,cAAc,CAAA;AAC1E,IAAM,uBAAA,GAA0BA,oBAAsC,mBAAmB,CAAA;AAEzF,SAAS,QAAA,GAAoB;AAC3B,EAAA,OAAO,OAAO,MAAA,KAAW,WAAA,IAAeC,cAAA,CAAU,gBAAA,EAAiB;AACrE;AAEA,eAAsB,aAAa,OAAA,EAId;AACnB,EAAA,IAAI,CAAC,QAAA,EAAS,IAAK,CAACA,cAAA,CAAU,iBAAA,CAAkB,WAAW,CAAA,EAAG;AAC5D,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,IAAI;AACF,IAAA,IAAI,QAAQ,KAAA,EAAO;AACjB,MAAA,MAAM,MAAA,GACJ,QAAQ,KAAA,KAAU,MAAA,GAAS,SAAS,OAAA,CAAQ,KAAA,KAAU,UAAU,OAAA,GAAU,SAAA;AAC5E,MAAA,MAAM,eAAA,CAAgB,QAAA,CAAS,EAAE,KAAA,EAAO,QAAQ,CAAA;AAAA,IAClD;AACA,IAAA,IAAI,OAAO,OAAA,CAAQ,OAAA,KAAY,SAAA,EAAW;AACxC,MAAA,MAAM,gBAAgB,kBAAA,CAAmB,EAAE,OAAA,EAAS,OAAA,CAAQ,SAAS,CAAA;AAAA,IACvE;AACA,IAAA,IAAI,OAAA,CAAQ,eAAA,IAAmBA,cAAA,CAAU,WAAA,OAAkB,SAAA,EAAW;AACpE,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AA,OAAO;AAAA,MACL,QAAA,EAAU,KAAA;AAAA,MACV,gBAAA,EAAkB,KAAA;AAAA,MAClB,YAAA,EAAc,KAAA;AAAA,MACd,iBAAA,EAAmB;AAAA,KACrB;AAAA,EACF;AAEA,EAAA,MAAM,CAAC,gBAAA,EAAkB,iBAAA,EAAmB,YAAY,CAAA,GAAI,MAAM,QAAQ,GAAA,CAAI;AAAA,IAC5E,MAAA,CAAO,kBACP,MAAA,CAAO,wBAAA,IACP,OAAO,MAAA,CAAO,gBAAA,KAAqB,YAC/B,YAAA,CAAa;AAAA,MACX,OAAO,MAAA,CAAO,cAAA;AAAA,MACd,iBAAiB,MAAA,CAAO,wBAAA;AAAA,MACxB,SAAS,MAAA,CAAO;AAAA,KACjB,CAAA,GACD,OAAA,CAAQ,OAAA,CAAQ,KAAK,CAAA;AAAA,IACzB,MAAA,CAAO,cAAc,eAAA,CAAgB,MAAA,CAAO,WAAW,CAAA,GAAI,OAAA,CAAQ,QAAQ,KAAK,CAAA;AAAA,IAChF,OAAO,UAAA,GAAa,gBAAA,EAAiB,GAAI,OAAA,CAAQ,QAAQ,KAAK;AAAA,GAC/D,CAAA;AAED,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,QAAA;AAAA,IACV,gBAAA;AAAA,IACA,YAAA;AAAA,IACA;AAAA,GACF;AACF","file":"shell.cjs","sourcesContent":["import { Capacitor, registerPlugin } from '@capacitor/core';\n\nexport type ShellStatusBarStyle = 'dark' | 'light' | 'default';\nexport type ShellOrientation = 'portrait' | 'landscape' | 'portrait-primary' | 'landscape-primary';\n\nexport interface ShellConfig {\n /** Status bar icon style (`'dark'` = light icons on dark bg, `'light'` = dark icons on light bg). */\n statusBarStyle?: ShellStatusBarStyle;\n /** Hex background color for Android status bar (e.g. `'#121212'`). */\n statusBarBackgroundColor?: string;\n /** Whether the WebView overlays the status bar (edge-to-edge). */\n statusBarOverlay?: boolean;\n /** Automatically hide `@capacitor/splash-screen` during `initShell()` (defaults to `false`). */\n hideSplash?: boolean;\n /** Lock screen orientation via `@capacitor/screen-orientation` if installed. */\n orientation?: ShellOrientation;\n}\n\nexport interface ShellInitResult {\n platform: 'native' | 'web';\n statusBarApplied: boolean;\n splashHidden: boolean;\n orientationLocked: boolean;\n}\n\ninterface StatusBarLike {\n setStyle(options: { style: 'DARK' | 'LIGHT' | 'DEFAULT' }): Promise<void>;\n setBackgroundColor(options: { color: string }): Promise<void>;\n setOverlaysWebView(options: { overlay: boolean }): Promise<void>;\n}\n\ninterface SplashScreenLike {\n hide(): Promise<void>;\n}\n\ninterface ScreenOrientationLike {\n lock(options: { orientation: ShellOrientation }): Promise<void>;\n unlock(): Promise<void>;\n}\n\nconst StatusBarPlugin = registerPlugin<StatusBarLike>('StatusBar');\nconst SplashScreenPlugin = registerPlugin<SplashScreenLike>('SplashScreen');\nconst ScreenOrientationPlugin = registerPlugin<ScreenOrientationLike>('ScreenOrientation');\n\nfunction isNative(): boolean {\n return typeof window !== 'undefined' && Capacitor.isNativePlatform();\n}\n\nexport async function setStatusBar(options: {\n style?: ShellStatusBarStyle;\n backgroundColor?: string;\n overlay?: boolean;\n}): Promise<boolean> {\n if (!isNative() || !Capacitor.isPluginAvailable('StatusBar')) {\n return false;\n }\n\n try {\n if (options.style) {\n const mapped =\n options.style === 'dark' ? 'DARK' : options.style === 'light' ? 'LIGHT' : 'DEFAULT';\n await StatusBarPlugin.setStyle({ style: mapped });\n }\n if (typeof options.overlay === 'boolean') {\n await StatusBarPlugin.setOverlaysWebView({ overlay: options.overlay });\n }\n if (options.backgroundColor && Capacitor.getPlatform() === 'android') {\n await StatusBarPlugin.setBackgroundColor({ color: options.backgroundColor });\n }\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function hideSplashScreen(): Promise<boolean> {\n if (!isNative() || !Capacitor.isPluginAvailable('SplashScreen')) {\n return false;\n }\n try {\n await SplashScreenPlugin.hide();\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function lockOrientation(orientation: ShellOrientation): Promise<boolean> {\n if (!isNative() || !Capacitor.isPluginAvailable('ScreenOrientation')) {\n return false;\n }\n try {\n await ScreenOrientationPlugin.lock({ orientation });\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function unlockOrientation(): Promise<boolean> {\n if (!isNative() || !Capacitor.isPluginAvailable('ScreenOrientation')) {\n return false;\n }\n try {\n await ScreenOrientationPlugin.unlock();\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Bootstraps common native mobile shell settings (StatusBar, SplashScreen, ScreenOrientation)\n * in a single idempotent, non-throwing call. Only touches Capacitor plugins that are actually\n * installed in the host app; safely no-ops on Web/SSR.\n */\nexport async function initShell(config: ShellConfig = {}): Promise<ShellInitResult> {\n if (!isNative()) {\n return {\n platform: 'web',\n statusBarApplied: false,\n splashHidden: false,\n orientationLocked: false,\n };\n }\n\n const [statusBarApplied, orientationLocked, splashHidden] = await Promise.all([\n config.statusBarStyle ||\n config.statusBarBackgroundColor ||\n typeof config.statusBarOverlay === 'boolean'\n ? setStatusBar({\n style: config.statusBarStyle,\n backgroundColor: config.statusBarBackgroundColor,\n overlay: config.statusBarOverlay,\n })\n : Promise.resolve(false),\n config.orientation ? lockOrientation(config.orientation) : Promise.resolve(false),\n config.hideSplash ? hideSplashScreen() : Promise.resolve(false),\n ]);\n\n return {\n platform: 'native',\n statusBarApplied,\n splashHidden,\n orientationLocked,\n };\n}\n"]}
@@ -0,0 +1,36 @@
1
+ type ShellStatusBarStyle = 'dark' | 'light' | 'default';
2
+ type ShellOrientation = 'portrait' | 'landscape' | 'portrait-primary' | 'landscape-primary';
3
+ interface ShellConfig {
4
+ /** Status bar icon style (`'dark'` = light icons on dark bg, `'light'` = dark icons on light bg). */
5
+ statusBarStyle?: ShellStatusBarStyle;
6
+ /** Hex background color for Android status bar (e.g. `'#121212'`). */
7
+ statusBarBackgroundColor?: string;
8
+ /** Whether the WebView overlays the status bar (edge-to-edge). */
9
+ statusBarOverlay?: boolean;
10
+ /** Automatically hide `@capacitor/splash-screen` during `initShell()` (defaults to `false`). */
11
+ hideSplash?: boolean;
12
+ /** Lock screen orientation via `@capacitor/screen-orientation` if installed. */
13
+ orientation?: ShellOrientation;
14
+ }
15
+ interface ShellInitResult {
16
+ platform: 'native' | 'web';
17
+ statusBarApplied: boolean;
18
+ splashHidden: boolean;
19
+ orientationLocked: boolean;
20
+ }
21
+ declare function setStatusBar(options: {
22
+ style?: ShellStatusBarStyle;
23
+ backgroundColor?: string;
24
+ overlay?: boolean;
25
+ }): Promise<boolean>;
26
+ declare function hideSplashScreen(): Promise<boolean>;
27
+ declare function lockOrientation(orientation: ShellOrientation): Promise<boolean>;
28
+ declare function unlockOrientation(): Promise<boolean>;
29
+ /**
30
+ * Bootstraps common native mobile shell settings (StatusBar, SplashScreen, ScreenOrientation)
31
+ * in a single idempotent, non-throwing call. Only touches Capacitor plugins that are actually
32
+ * installed in the host app; safely no-ops on Web/SSR.
33
+ */
34
+ declare function initShell(config?: ShellConfig): Promise<ShellInitResult>;
35
+
36
+ export { type ShellConfig, type ShellInitResult, type ShellOrientation, type ShellStatusBarStyle, hideSplashScreen, initShell, lockOrientation, setStatusBar, unlockOrientation };
@@ -0,0 +1,36 @@
1
+ type ShellStatusBarStyle = 'dark' | 'light' | 'default';
2
+ type ShellOrientation = 'portrait' | 'landscape' | 'portrait-primary' | 'landscape-primary';
3
+ interface ShellConfig {
4
+ /** Status bar icon style (`'dark'` = light icons on dark bg, `'light'` = dark icons on light bg). */
5
+ statusBarStyle?: ShellStatusBarStyle;
6
+ /** Hex background color for Android status bar (e.g. `'#121212'`). */
7
+ statusBarBackgroundColor?: string;
8
+ /** Whether the WebView overlays the status bar (edge-to-edge). */
9
+ statusBarOverlay?: boolean;
10
+ /** Automatically hide `@capacitor/splash-screen` during `initShell()` (defaults to `false`). */
11
+ hideSplash?: boolean;
12
+ /** Lock screen orientation via `@capacitor/screen-orientation` if installed. */
13
+ orientation?: ShellOrientation;
14
+ }
15
+ interface ShellInitResult {
16
+ platform: 'native' | 'web';
17
+ statusBarApplied: boolean;
18
+ splashHidden: boolean;
19
+ orientationLocked: boolean;
20
+ }
21
+ declare function setStatusBar(options: {
22
+ style?: ShellStatusBarStyle;
23
+ backgroundColor?: string;
24
+ overlay?: boolean;
25
+ }): Promise<boolean>;
26
+ declare function hideSplashScreen(): Promise<boolean>;
27
+ declare function lockOrientation(orientation: ShellOrientation): Promise<boolean>;
28
+ declare function unlockOrientation(): Promise<boolean>;
29
+ /**
30
+ * Bootstraps common native mobile shell settings (StatusBar, SplashScreen, ScreenOrientation)
31
+ * in a single idempotent, non-throwing call. Only touches Capacitor plugins that are actually
32
+ * installed in the host app; safely no-ops on Web/SSR.
33
+ */
34
+ declare function initShell(config?: ShellConfig): Promise<ShellInitResult>;
35
+
36
+ export { type ShellConfig, type ShellInitResult, type ShellOrientation, type ShellStatusBarStyle, hideSplashScreen, initShell, lockOrientation, setStatusBar, unlockOrientation };
package/dist/shell.js ADDED
@@ -0,0 +1,91 @@
1
+ import { registerPlugin, Capacitor } from '@capacitor/core';
2
+
3
+ // src/shell.ts
4
+ var StatusBarPlugin = registerPlugin("StatusBar");
5
+ var SplashScreenPlugin = registerPlugin("SplashScreen");
6
+ var ScreenOrientationPlugin = registerPlugin("ScreenOrientation");
7
+ function isNative() {
8
+ return typeof window !== "undefined" && Capacitor.isNativePlatform();
9
+ }
10
+ async function setStatusBar(options) {
11
+ if (!isNative() || !Capacitor.isPluginAvailable("StatusBar")) {
12
+ return false;
13
+ }
14
+ try {
15
+ if (options.style) {
16
+ const mapped = options.style === "dark" ? "DARK" : options.style === "light" ? "LIGHT" : "DEFAULT";
17
+ await StatusBarPlugin.setStyle({ style: mapped });
18
+ }
19
+ if (typeof options.overlay === "boolean") {
20
+ await StatusBarPlugin.setOverlaysWebView({ overlay: options.overlay });
21
+ }
22
+ if (options.backgroundColor && Capacitor.getPlatform() === "android") {
23
+ await StatusBarPlugin.setBackgroundColor({ color: options.backgroundColor });
24
+ }
25
+ return true;
26
+ } catch {
27
+ return false;
28
+ }
29
+ }
30
+ async function hideSplashScreen() {
31
+ if (!isNative() || !Capacitor.isPluginAvailable("SplashScreen")) {
32
+ return false;
33
+ }
34
+ try {
35
+ await SplashScreenPlugin.hide();
36
+ return true;
37
+ } catch {
38
+ return false;
39
+ }
40
+ }
41
+ async function lockOrientation(orientation) {
42
+ if (!isNative() || !Capacitor.isPluginAvailable("ScreenOrientation")) {
43
+ return false;
44
+ }
45
+ try {
46
+ await ScreenOrientationPlugin.lock({ orientation });
47
+ return true;
48
+ } catch {
49
+ return false;
50
+ }
51
+ }
52
+ async function unlockOrientation() {
53
+ if (!isNative() || !Capacitor.isPluginAvailable("ScreenOrientation")) {
54
+ return false;
55
+ }
56
+ try {
57
+ await ScreenOrientationPlugin.unlock();
58
+ return true;
59
+ } catch {
60
+ return false;
61
+ }
62
+ }
63
+ async function initShell(config = {}) {
64
+ if (!isNative()) {
65
+ return {
66
+ platform: "web",
67
+ statusBarApplied: false,
68
+ splashHidden: false,
69
+ orientationLocked: false
70
+ };
71
+ }
72
+ const [statusBarApplied, orientationLocked, splashHidden] = await Promise.all([
73
+ config.statusBarStyle || config.statusBarBackgroundColor || typeof config.statusBarOverlay === "boolean" ? setStatusBar({
74
+ style: config.statusBarStyle,
75
+ backgroundColor: config.statusBarBackgroundColor,
76
+ overlay: config.statusBarOverlay
77
+ }) : Promise.resolve(false),
78
+ config.orientation ? lockOrientation(config.orientation) : Promise.resolve(false),
79
+ config.hideSplash ? hideSplashScreen() : Promise.resolve(false)
80
+ ]);
81
+ return {
82
+ platform: "native",
83
+ statusBarApplied,
84
+ splashHidden,
85
+ orientationLocked
86
+ };
87
+ }
88
+
89
+ export { hideSplashScreen, initShell, lockOrientation, setStatusBar, unlockOrientation };
90
+ //# sourceMappingURL=shell.js.map
91
+ //# sourceMappingURL=shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/shell.ts"],"names":[],"mappings":";;;AAwCA,IAAM,eAAA,GAAkB,eAA8B,WAAW,CAA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O,MAAA,CAAO,cAAA;AAAA,MACd,iBAAiB,MAAA,CAAO,wBAAA;AAAA,MACxB,SAAS,MAAA,CAAO;AAAA,KACjB,CAAA,GACD,OAAA,CAAQ,OAAA,CAAQ,KAAK,CAAA;AAAA,IACzB,MAAA,CAAO,cAAc,eAAA,CAAgB,MAAA,CAAO,WAAW,CAAA,GAAI,OAAA,CAAQ,QAAQ,KAAK,CAAA;AAAA,IAChF,OAAO,UAAA,GAAa,gBAAA,EAAiB,GAAI,OAAA,CAAQ,QAAQ,KAAK;AAAA,GAC/D,CAAA;AAED,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,QAAA;AAAA,IACV,gBAAA;AAAA,IACA,YAAA;AAAA,IACA;AAAA,GACF;AACF","file":"shell.js","sourcesContent":["import { Capacitor, registerPlugin } from '@capacitor/core';\n\nexport type ShellStatusBarStyle = 'dark' | 'light' | 'default';\nexport type ShellOrientation = 'portrait' | 'landscape' | 'portrait-primary' | 'landscape-primary';\n\nexport interface ShellConfig {\n /** Status bar icon style (`'dark'` = light icons on dark bg, `'light'` = dark icons on light bg). */\n statusBarStyle?: ShellStatusBarStyle;\n /** Hex background color for Android status bar (e.g. `'#121212'`). */\n statusBarBackgroundColor?: string;\n /** Whether the WebView overlays the status bar (edge-to-edge). */\n statusBarOverlay?: boolean;\n /** Automatically hide `@capacitor/splash-screen` during `initShell()` (defaults to `false`). */\n hideSplash?: boolean;\n /** Lock screen orientation via `@capacitor/screen-orientation` if installed. */\n orientation?: ShellOrientation;\n}\n\nexport interface ShellInitResult {\n platform: 'native' | 'web';\n statusBarApplied: boolean;\n splashHidden: boolean;\n orientationLocked: boolean;\n}\n\ninterface StatusBarLike {\n setStyle(options: { style: 'DARK' | 'LIGHT' | 'DEFAULT' }): Promise<void>;\n setBackgroundColor(options: { color: string }): Promise<void>;\n setOverlaysWebView(options: { overlay: boolean }): Promise<void>;\n}\n\ninterface SplashScreenLike {\n hide(): Promise<void>;\n}\n\ninterface ScreenOrientationLike {\n lock(options: { orientation: ShellOrientation }): Promise<void>;\n unlock(): Promise<void>;\n}\n\nconst StatusBarPlugin = registerPlugin<StatusBarLike>('StatusBar');\nconst SplashScreenPlugin = registerPlugin<SplashScreenLike>('SplashScreen');\nconst ScreenOrientationPlugin = registerPlugin<ScreenOrientationLike>('ScreenOrientation');\n\nfunction isNative(): boolean {\n return typeof window !== 'undefined' && Capacitor.isNativePlatform();\n}\n\nexport async function setStatusBar(options: {\n style?: ShellStatusBarStyle;\n backgroundColor?: string;\n overlay?: boolean;\n}): Promise<boolean> {\n if (!isNative() || !Capacitor.isPluginAvailable('StatusBar')) {\n return false;\n }\n\n try {\n if (options.style) {\n const mapped =\n options.style === 'dark' ? 'DARK' : options.style === 'light' ? 'LIGHT' : 'DEFAULT';\n await StatusBarPlugin.setStyle({ style: mapped });\n }\n if (typeof options.overlay === 'boolean') {\n await StatusBarPlugin.setOverlaysWebView({ overlay: options.overlay });\n }\n if (options.backgroundColor && Capacitor.getPlatform() === 'android') {\n await StatusBarPlugin.setBackgroundColor({ color: options.backgroundColor });\n }\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function hideSplashScreen(): Promise<boolean> {\n if (!isNative() || !Capacitor.isPluginAvailable('SplashScreen')) {\n return false;\n }\n try {\n await SplashScreenPlugin.hide();\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function lockOrientation(orientation: ShellOrientation): Promise<boolean> {\n if (!isNative() || !Capacitor.isPluginAvailable('ScreenOrientation')) {\n return false;\n }\n try {\n await ScreenOrientationPlugin.lock({ orientation });\n return true;\n } catch {\n return false;\n }\n}\n\nexport async function unlockOrientation(): Promise<boolean> {\n if (!isNative() || !Capacitor.isPluginAvailable('ScreenOrientation')) {\n return false;\n }\n try {\n await ScreenOrientationPlugin.unlock();\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Bootstraps common native mobile shell settings (StatusBar, SplashScreen, ScreenOrientation)\n * in a single idempotent, non-throwing call. Only touches Capacitor plugins that are actually\n * installed in the host app; safely no-ops on Web/SSR.\n */\nexport async function initShell(config: ShellConfig = {}): Promise<ShellInitResult> {\n if (!isNative()) {\n return {\n platform: 'web',\n statusBarApplied: false,\n splashHidden: false,\n orientationLocked: false,\n };\n }\n\n const [statusBarApplied, orientationLocked, splashHidden] = await Promise.all([\n config.statusBarStyle ||\n config.statusBarBackgroundColor ||\n typeof config.statusBarOverlay === 'boolean'\n ? setStatusBar({\n style: config.statusBarStyle,\n backgroundColor: config.statusBarBackgroundColor,\n overlay: config.statusBarOverlay,\n })\n : Promise.resolve(false),\n config.orientation ? lockOrientation(config.orientation) : Promise.resolve(false),\n config.hideSplash ? hideSplashScreen() : Promise.resolve(false),\n ]);\n\n return {\n platform: 'native',\n statusBarApplied,\n splashHidden,\n orientationLocked,\n };\n}\n"]}
@@ -0,0 +1,140 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ // src/storage.ts
6
+ var SimaStorage = core.registerPlugin("SimaStorage");
7
+ var memoryFallback = /* @__PURE__ */ new Map();
8
+ function canUseNativeStorage() {
9
+ return typeof window !== "undefined" && core.Capacitor.isNativePlatform() && core.Capacitor.isPluginAvailable("SimaStorage");
10
+ }
11
+ var defaultStorageBackend = {
12
+ async getItem(key) {
13
+ if (canUseNativeStorage()) {
14
+ const { value } = await SimaStorage.get({ key });
15
+ return value ?? null;
16
+ }
17
+ if (typeof window !== "undefined" && typeof window.localStorage !== "undefined") {
18
+ try {
19
+ return window.localStorage.getItem(key);
20
+ } catch {
21
+ return memoryFallback.get(key) ?? null;
22
+ }
23
+ }
24
+ return memoryFallback.get(key) ?? null;
25
+ },
26
+ async setItem(key, value) {
27
+ if (canUseNativeStorage()) {
28
+ await SimaStorage.set({ key, value });
29
+ return;
30
+ }
31
+ if (typeof window !== "undefined" && typeof window.localStorage !== "undefined") {
32
+ try {
33
+ window.localStorage.setItem(key, value);
34
+ return;
35
+ } catch {
36
+ memoryFallback.set(key, value);
37
+ return;
38
+ }
39
+ }
40
+ memoryFallback.set(key, value);
41
+ },
42
+ async removeItem(key) {
43
+ if (canUseNativeStorage()) {
44
+ await SimaStorage.remove({ key });
45
+ return;
46
+ }
47
+ if (typeof window !== "undefined" && typeof window.localStorage !== "undefined") {
48
+ try {
49
+ window.localStorage.removeItem(key);
50
+ return;
51
+ } catch {
52
+ memoryFallback.delete(key);
53
+ return;
54
+ }
55
+ }
56
+ memoryFallback.delete(key);
57
+ },
58
+ async clearPrefix(prefix) {
59
+ if (canUseNativeStorage()) {
60
+ await SimaStorage.clearPrefix({ prefix });
61
+ return;
62
+ }
63
+ if (typeof window !== "undefined" && typeof window.localStorage !== "undefined") {
64
+ try {
65
+ const toDelete = [];
66
+ for (let i = 0; i < window.localStorage.length; i += 1) {
67
+ const k = window.localStorage.key(i);
68
+ if (k && k.startsWith(prefix)) {
69
+ toDelete.push(k);
70
+ }
71
+ }
72
+ for (const k of toDelete) {
73
+ window.localStorage.removeItem(k);
74
+ }
75
+ return;
76
+ } catch {
77
+ }
78
+ }
79
+ for (const k of Array.from(memoryFallback.keys())) {
80
+ if (k.startsWith(prefix)) {
81
+ memoryFallback.delete(k);
82
+ }
83
+ }
84
+ }
85
+ };
86
+ function createStorage(config = {}) {
87
+ const namespace = config.namespace ?? "default";
88
+ const version = config.version ?? 1;
89
+ const backend = config.backend ?? defaultStorageBackend;
90
+ const prefix = `simasdk:store:${namespace}:`;
91
+ function fullKey(key) {
92
+ return `${prefix}${key}`;
93
+ }
94
+ async function readOptional(key) {
95
+ const raw = await backend.getItem(fullKey(key));
96
+ if (raw === null) {
97
+ return null;
98
+ }
99
+ try {
100
+ const parsed = JSON.parse(raw);
101
+ if (typeof parsed !== "object" || parsed === null || !("d" in parsed)) {
102
+ return null;
103
+ }
104
+ const storedVersion = typeof parsed.v === "number" ? parsed.v : 1;
105
+ if (storedVersion !== version && config.migrate) {
106
+ const migrated = config.migrate(key, parsed.d, storedVersion);
107
+ await backend.setItem(fullKey(key), JSON.stringify({ v: version, d: migrated }));
108
+ return migrated;
109
+ }
110
+ return parsed.d;
111
+ } catch {
112
+ return null;
113
+ }
114
+ }
115
+ return {
116
+ async get(key, fallback) {
117
+ const value = await readOptional(key);
118
+ return value === null ? fallback : value;
119
+ },
120
+ getOptional: readOptional,
121
+ async set(key, value) {
122
+ const envelope = { v: version, d: value };
123
+ await backend.setItem(fullKey(key), JSON.stringify(envelope));
124
+ },
125
+ async remove(key) {
126
+ await backend.removeItem(fullKey(key));
127
+ },
128
+ async clear() {
129
+ if (backend.clearPrefix) {
130
+ await backend.clearPrefix(prefix);
131
+ }
132
+ }
133
+ };
134
+ }
135
+
136
+ exports.SimaStorage = SimaStorage;
137
+ exports.createStorage = createStorage;
138
+ exports.defaultStorageBackend = defaultStorageBackend;
139
+ //# sourceMappingURL=storage.cjs.map
140
+ //# sourceMappingURL=storage.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/storage.ts"],"names":["registerPlugin","Capacitor"],"mappings":";;;;;AASO,IAAM,WAAA,GAAcA,oBAAwC,aAAa;AAoChF,IAAM,cAAA,uBAAqB,GAAA,EAAoB;AAE/C,SAAS,mBAAA,GAA+B;AACtC,EAAA,OACE,OAAO,WAAW,WAAA,IAClBC,cAAA,CAAU,kBAAiB,IAC3BA,cAAA,CAAU,kBAAkB,aAAa,CAAA;AAE7C;AAEO,IAAM,qBAAA,GAAwC;AAAA,EACnD,MAAM,QAAQ,GAAA,EAAqC;AACjD,IAAA,IAAI,qBAAoB,EAAG;AACzB,MAAA,MAAM,EAAE,OAAM,GAAI,MAAM,YAAY,GAAA,CAAI,EAAE,KAAK,CAAA;AAC/C,MAAA,OAAO,KAAA,IAAS,IAAA;AAAA,IAClB;AACA,IAAA,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,OAAO,MAAA,CAAO,iBAAiB,WAAA,EAAa;AAC/E,MAAA,IAAI;AACF,QAAA,OAAO,MAAA,CAAO,YAAA,CAAa,OAAA,CAAQ,GAAG,CAAA;AAAA,MACxC,CAAA,CAAA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AyB;AACjD,MAAA,MAAM,KAAA,GAAQ,MAAM,YAAA,CAAgB,GAAG,CAAA;AACvC,MAAA,OAAO,KAAA,KAAU,OAAO,QAAA,GAAW,KAAA;AAAA,IACrC,CAAA;AAAA,IAEA,WAAA,EAAa,YAAA;AAAA,IAEb,MAAM,GAAA,CAAO,GAAA,EAAa,KAAA,EAAyB;AACjD,MAAA,MAAM,QAAA,GAA8B,EAAE,CAAA,EAAG,OAAA,EAAS,GAAG,KAAA,EAAM;AAC3D,MAAA,MAAM,OAAA,CAAQ,QAAQ,OAAA,CAAQ,GAAG,GAAG,IAAA,CAAK,SAAA,CAAU,QAAQ,CAAC,CAAA;AAAA,IAC9D,CAAA;AAAA,IAEA,MAAM,OAAO,GAAA,EAA4B;AACvC,MAAA,MAAM,OAAA,CAAQ,UAAA,CAAW,OAAA,CAAQ,GAAG,CAAC,CAAA;AAAA,IACvC,CAAA;AAAA,IAEA,MAAM,KAAA,GAAuB;AAC3B,MAAA,IAAI,QAAQ,WAAA,EAAa;AACvB,QAAA,MAAM,OAAA,CAAQ,YAAY,MAAM,CAAA;AAAA,MAClC;AAAA,IACF;AAAA,GACF;AACF","file":"storage.cjs","sourcesContent":["import { Capacitor, registerPlugin } from '@capacitor/core';\n\nexport interface SimaStorageNativePlugin {\n get(options: { key: string }): Promise<{ value: string | null }>;\n set(options: { key: string; value: string }): Promise<void>;\n remove(options: { key: string }): Promise<void>;\n clearPrefix(options: { prefix: string }): Promise<void>;\n}\n\nexport const SimaStorage = registerPlugin<SimaStorageNativePlugin>('SimaStorage');\n\nexport interface StorageBackend {\n getItem(key: string): string | null | Promise<string | null>;\n setItem(key: string, value: string): void | Promise<void>;\n removeItem(key: string): void | Promise<void>;\n clearPrefix?(prefix: string): void | Promise<void>;\n}\n\nexport interface StorageConfig {\n /** Namespace prefix isolating keys for this store (e.g. `\"settings\"` or `\"game\"`). */\n namespace?: string;\n /** Optional schema version for stored envelopes (defaults to `1`). */\n version?: number;\n /**\n * Optional migration function called when a stored value has an older schema version.\n * Return the migrated value for the current version.\n */\n migrate?: (key: string, oldValue: unknown, fromVersion: number) => unknown;\n /** Optional custom storage backend (primarily for testing). */\n backend?: StorageBackend;\n}\n\nexport interface SimaStore {\n get<T>(key: string, fallback: T): Promise<T>;\n getOptional<T>(key: string): Promise<T | null>;\n set<T>(key: string, value: T): Promise<void>;\n remove(key: string): Promise<void>;\n clear(): Promise<void>;\n}\n\ninterface StoredEnvelope<T> {\n v: number;\n d: T;\n}\n\nconst memoryFallback = new Map<string, string>();\n\nfunction canUseNativeStorage(): boolean {\n return (\n typeof window !== 'undefined' &&\n Capacitor.isNativePlatform() &&\n Capacitor.isPluginAvailable('SimaStorage')\n );\n}\n\nexport const defaultStorageBackend: StorageBackend = {\n async getItem(key: string): Promise<string | null> {\n if (canUseNativeStorage()) {\n const { value } = await SimaStorage.get({ key });\n return value ?? null;\n }\n if (typeof window !== 'undefined' && typeof window.localStorage !== 'undefined') {\n try {\n return window.localStorage.getItem(key);\n } catch {\n return memoryFallback.get(key) ?? null;\n }\n }\n return memoryFallback.get(key) ?? null;\n },\n\n async setItem(key: string, value: string): Promise<void> {\n if (canUseNativeStorage()) {\n await SimaStorage.set({ key, value });\n return;\n }\n if (typeof window !== 'undefined' && typeof window.localStorage !== 'undefined') {\n try {\n window.localStorage.setItem(key, value);\n return;\n } catch {\n memoryFallback.set(key, value);\n return;\n }\n }\n memoryFallback.set(key, value);\n },\n\n async removeItem(key: string): Promise<void> {\n if (canUseNativeStorage()) {\n await SimaStorage.remove({ key });\n return;\n }\n if (typeof window !== 'undefined' && typeof window.localStorage !== 'undefined') {\n try {\n window.localStorage.removeItem(key);\n return;\n } catch {\n memoryFallback.delete(key);\n return;\n }\n }\n memoryFallback.delete(key);\n },\n\n async clearPrefix(prefix: string): Promise<void> {\n if (canUseNativeStorage()) {\n await SimaStorage.clearPrefix({ prefix });\n return;\n }\n if (typeof window !== 'undefined' && typeof window.localStorage !== 'undefined') {\n try {\n const toDelete: string[] = [];\n for (let i = 0; i < window.localStorage.length; i += 1) {\n const k = window.localStorage.key(i);\n if (k && k.startsWith(prefix)) {\n toDelete.push(k);\n }\n }\n for (const k of toDelete) {\n window.localStorage.removeItem(k);\n }\n return;\n } catch {\n // Fall through to memoryFallback cleanup.\n }\n }\n for (const k of Array.from(memoryFallback.keys())) {\n if (k.startsWith(prefix)) {\n memoryFallback.delete(k);\n }\n }\n },\n};\n\nexport function createStorage(config: StorageConfig = {}): SimaStore {\n const namespace = config.namespace ?? 'default';\n const version = config.version ?? 1;\n const backend = config.backend ?? defaultStorageBackend;\n const prefix = `simasdk:store:${namespace}:`;\n\n function fullKey(key: string): string {\n return `${prefix}${key}`;\n }\n\n async function readOptional<T>(key: string): Promise<T | null> {\n const raw = await backend.getItem(fullKey(key));\n if (raw === null) {\n return null;\n }\n try {\n const parsed = JSON.parse(raw) as Partial<StoredEnvelope<T>>;\n if (typeof parsed !== 'object' || parsed === null || !('d' in parsed)) {\n return null;\n }\n const storedVersion = typeof parsed.v === 'number' ? parsed.v : 1;\n if (storedVersion !== version && config.migrate) {\n const migrated = config.migrate(key, parsed.d, storedVersion) as T;\n await backend.setItem(fullKey(key), JSON.stringify({ v: version, d: migrated }));\n return migrated;\n }\n return parsed.d as T;\n } catch {\n return null;\n }\n }\n\n return {\n async get<T>(key: string, fallback: T): Promise<T> {\n const value = await readOptional<T>(key);\n return value === null ? fallback : value;\n },\n\n getOptional: readOptional,\n\n async set<T>(key: string, value: T): Promise<void> {\n const envelope: StoredEnvelope<T> = { v: version, d: value };\n await backend.setItem(fullKey(key), JSON.stringify(envelope));\n },\n\n async remove(key: string): Promise<void> {\n await backend.removeItem(fullKey(key));\n },\n\n async clear(): Promise<void> {\n if (backend.clearPrefix) {\n await backend.clearPrefix(prefix);\n }\n },\n };\n}\n"]}
@@ -0,0 +1,48 @@
1
+ interface SimaStorageNativePlugin {
2
+ get(options: {
3
+ key: string;
4
+ }): Promise<{
5
+ value: string | null;
6
+ }>;
7
+ set(options: {
8
+ key: string;
9
+ value: string;
10
+ }): Promise<void>;
11
+ remove(options: {
12
+ key: string;
13
+ }): Promise<void>;
14
+ clearPrefix(options: {
15
+ prefix: string;
16
+ }): Promise<void>;
17
+ }
18
+ declare const SimaStorage: SimaStorageNativePlugin;
19
+ interface StorageBackend {
20
+ getItem(key: string): string | null | Promise<string | null>;
21
+ setItem(key: string, value: string): void | Promise<void>;
22
+ removeItem(key: string): void | Promise<void>;
23
+ clearPrefix?(prefix: string): void | Promise<void>;
24
+ }
25
+ interface StorageConfig {
26
+ /** Namespace prefix isolating keys for this store (e.g. `"settings"` or `"game"`). */
27
+ namespace?: string;
28
+ /** Optional schema version for stored envelopes (defaults to `1`). */
29
+ version?: number;
30
+ /**
31
+ * Optional migration function called when a stored value has an older schema version.
32
+ * Return the migrated value for the current version.
33
+ */
34
+ migrate?: (key: string, oldValue: unknown, fromVersion: number) => unknown;
35
+ /** Optional custom storage backend (primarily for testing). */
36
+ backend?: StorageBackend;
37
+ }
38
+ interface SimaStore {
39
+ get<T>(key: string, fallback: T): Promise<T>;
40
+ getOptional<T>(key: string): Promise<T | null>;
41
+ set<T>(key: string, value: T): Promise<void>;
42
+ remove(key: string): Promise<void>;
43
+ clear(): Promise<void>;
44
+ }
45
+ declare const defaultStorageBackend: StorageBackend;
46
+ declare function createStorage(config?: StorageConfig): SimaStore;
47
+
48
+ export { SimaStorage, type SimaStorageNativePlugin, type SimaStore, type StorageBackend, type StorageConfig, createStorage, defaultStorageBackend };
@@ -0,0 +1,48 @@
1
+ interface SimaStorageNativePlugin {
2
+ get(options: {
3
+ key: string;
4
+ }): Promise<{
5
+ value: string | null;
6
+ }>;
7
+ set(options: {
8
+ key: string;
9
+ value: string;
10
+ }): Promise<void>;
11
+ remove(options: {
12
+ key: string;
13
+ }): Promise<void>;
14
+ clearPrefix(options: {
15
+ prefix: string;
16
+ }): Promise<void>;
17
+ }
18
+ declare const SimaStorage: SimaStorageNativePlugin;
19
+ interface StorageBackend {
20
+ getItem(key: string): string | null | Promise<string | null>;
21
+ setItem(key: string, value: string): void | Promise<void>;
22
+ removeItem(key: string): void | Promise<void>;
23
+ clearPrefix?(prefix: string): void | Promise<void>;
24
+ }
25
+ interface StorageConfig {
26
+ /** Namespace prefix isolating keys for this store (e.g. `"settings"` or `"game"`). */
27
+ namespace?: string;
28
+ /** Optional schema version for stored envelopes (defaults to `1`). */
29
+ version?: number;
30
+ /**
31
+ * Optional migration function called when a stored value has an older schema version.
32
+ * Return the migrated value for the current version.
33
+ */
34
+ migrate?: (key: string, oldValue: unknown, fromVersion: number) => unknown;
35
+ /** Optional custom storage backend (primarily for testing). */
36
+ backend?: StorageBackend;
37
+ }
38
+ interface SimaStore {
39
+ get<T>(key: string, fallback: T): Promise<T>;
40
+ getOptional<T>(key: string): Promise<T | null>;
41
+ set<T>(key: string, value: T): Promise<void>;
42
+ remove(key: string): Promise<void>;
43
+ clear(): Promise<void>;
44
+ }
45
+ declare const defaultStorageBackend: StorageBackend;
46
+ declare function createStorage(config?: StorageConfig): SimaStore;
47
+
48
+ export { SimaStorage, type SimaStorageNativePlugin, type SimaStore, type StorageBackend, type StorageConfig, createStorage, defaultStorageBackend };