native-fn 1.0.26 → 1.0.27

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 (146) hide show
  1. package/README.md +22 -192
  2. package/dist/index.d.ts +4 -28
  3. package/dist/native.cjs +27 -1400
  4. package/dist/native.min.cjs +1 -0
  5. package/dist/native.min.mjs +1 -0
  6. package/dist/native.mjs +27 -1400
  7. package/dist/native.umd.js +27 -1400
  8. package/dist/native.umd.min.js +1 -0
  9. package/dist/plugin/app/index.cjs +1025 -0
  10. package/dist/plugin/app/index.d.ts +4 -0
  11. package/dist/plugin/app/index.min.cjs +1 -0
  12. package/dist/plugin/app/index.min.mjs +1 -0
  13. package/dist/plugin/app/index.mjs +1023 -0
  14. package/dist/plugin/app/index.umd.js +1031 -0
  15. package/dist/plugin/app/index.umd.min.js +1 -0
  16. package/dist/plugin/app/src/constants/platform.d.ts +35 -0
  17. package/dist/plugin/app/src/constants/user-agent.d.ts +1 -0
  18. package/dist/{src → plugin/app/src/plugin/app}/cores/app.d.ts +1 -1
  19. package/dist/plugin/app/src/plugin/app/index.d.ts +5 -0
  20. package/dist/plugin/app/src/plugin/app/types/app.d.ts +54 -0
  21. package/dist/plugin/app/src/plugin/app/types/index.d.ts +1 -0
  22. package/dist/plugin/app/src/plugin/app/utils/event-listener-utils.d.ts +3 -0
  23. package/dist/{src → plugin/app/src/plugin/platform}/cores/platform.d.ts +1 -1
  24. package/dist/plugin/app/src/plugin/platform/index.d.ts +5 -0
  25. package/dist/plugin/app/src/plugin/platform/types/index.d.ts +1 -0
  26. package/dist/{src → plugin/app/src/plugin/platform}/types/platform.d.ts +1 -1
  27. package/dist/{src → plugin/app/src/plugin/theme}/constants/theme.d.ts +1 -1
  28. package/dist/{src → plugin/app/src/plugin/theme}/cores/theme.d.ts +1 -1
  29. package/dist/plugin/app/src/plugin/theme/index.d.ts +5 -0
  30. package/dist/plugin/app/src/plugin/theme/types/color.d.ts +17 -0
  31. package/dist/{src → plugin/app/src/plugin/theme}/types/easing-syntax.d.ts +1 -1
  32. package/dist/plugin/app/src/plugin/theme/types/index.d.ts +3 -0
  33. package/dist/{src → plugin/app/src/plugin/theme}/types/theme.d.ts +4 -4
  34. package/dist/{src → plugin/app/src/plugin/theme}/utils/parse-color.d.ts +1 -1
  35. package/dist/{src → plugin/app/src/plugin/theme}/utils/parse-easing-function.d.ts +1 -1
  36. package/dist/plugin/app/src/types/index.d.ts +1 -0
  37. package/dist/plugin/app/src/types/native.d.ts +14 -0
  38. package/dist/plugin/app/src/utils/assign.d.ts +1 -0
  39. package/dist/plugin/app/src/utils/create-custom-error.d.ts +1 -0
  40. package/dist/plugin/platform/index.cjs +171 -0
  41. package/dist/plugin/platform/index.d.ts +4 -0
  42. package/dist/plugin/platform/index.min.cjs +1 -0
  43. package/dist/plugin/platform/index.min.mjs +1 -0
  44. package/dist/plugin/platform/index.mjs +169 -0
  45. package/dist/plugin/platform/index.umd.js +177 -0
  46. package/dist/plugin/platform/index.umd.min.js +1 -0
  47. package/dist/plugin/platform/src/constants/platform.d.ts +35 -0
  48. package/dist/plugin/platform/src/constants/user-agent.d.ts +1 -0
  49. package/dist/plugin/platform/src/plugin/app/constants/app.d.ts +13 -0
  50. package/dist/plugin/platform/src/plugin/app/cores/app.d.ts +3 -0
  51. package/dist/plugin/platform/src/plugin/app/errors/url-open-error.d.ts +2 -0
  52. package/dist/plugin/platform/src/plugin/app/index.d.ts +5 -0
  53. package/dist/plugin/platform/src/plugin/app/types/app.d.ts +54 -0
  54. package/dist/plugin/platform/src/plugin/app/types/index.d.ts +1 -0
  55. package/dist/plugin/platform/src/plugin/app/utils/event-listener-utils.d.ts +3 -0
  56. package/dist/plugin/platform/src/plugin/app/utils/try-open-url.d.ts +1 -0
  57. package/dist/plugin/platform/src/plugin/platform/cores/platform.d.ts +3 -0
  58. package/dist/plugin/platform/src/plugin/platform/index.d.ts +5 -0
  59. package/dist/plugin/platform/src/plugin/platform/types/index.d.ts +1 -0
  60. package/dist/plugin/platform/src/plugin/platform/types/platform.d.ts +13 -0
  61. package/dist/plugin/platform/src/plugin/theme/constants/theme.d.ts +16 -0
  62. package/dist/plugin/platform/src/plugin/theme/cores/theme.d.ts +3 -0
  63. package/dist/plugin/platform/src/plugin/theme/errors/easing-error.d.ts +6 -0
  64. package/dist/plugin/platform/src/plugin/theme/errors/unsupported-color-error.d.ts +2 -0
  65. package/dist/plugin/platform/src/plugin/theme/index.d.ts +5 -0
  66. package/dist/plugin/platform/src/plugin/theme/types/color.d.ts +17 -0
  67. package/dist/plugin/platform/src/plugin/theme/types/easing-syntax.d.ts +16 -0
  68. package/dist/plugin/platform/src/plugin/theme/types/index.d.ts +3 -0
  69. package/dist/plugin/platform/src/plugin/theme/types/theme.d.ts +24 -0
  70. package/dist/plugin/platform/src/plugin/theme/utils/parse-color.d.ts +2 -0
  71. package/dist/plugin/platform/src/plugin/theme/utils/parse-easing-function.d.ts +2 -0
  72. package/dist/plugin/platform/src/types/index.d.ts +1 -0
  73. package/dist/plugin/platform/src/types/native.d.ts +14 -0
  74. package/dist/plugin/platform/src/utils/assign.d.ts +1 -0
  75. package/dist/plugin/platform/src/utils/create-custom-error.d.ts +1 -0
  76. package/dist/plugin/theme/index.cjs +810 -0
  77. package/dist/plugin/theme/index.d.ts +4 -0
  78. package/dist/plugin/theme/index.min.cjs +1 -0
  79. package/dist/plugin/theme/index.min.mjs +1 -0
  80. package/dist/plugin/theme/index.mjs +808 -0
  81. package/dist/plugin/theme/index.umd.js +816 -0
  82. package/dist/plugin/theme/index.umd.min.js +1 -0
  83. package/dist/plugin/theme/src/constants/platform.d.ts +35 -0
  84. package/dist/plugin/theme/src/constants/user-agent.d.ts +1 -0
  85. package/dist/plugin/theme/src/plugin/app/constants/app.d.ts +13 -0
  86. package/dist/plugin/theme/src/plugin/app/cores/app.d.ts +3 -0
  87. package/dist/plugin/theme/src/plugin/app/errors/url-open-error.d.ts +2 -0
  88. package/dist/plugin/theme/src/plugin/app/index.d.ts +5 -0
  89. package/dist/plugin/theme/src/plugin/app/types/app.d.ts +54 -0
  90. package/dist/plugin/theme/src/plugin/app/types/index.d.ts +1 -0
  91. package/dist/plugin/theme/src/plugin/app/utils/event-listener-utils.d.ts +3 -0
  92. package/dist/plugin/theme/src/plugin/app/utils/try-open-url.d.ts +1 -0
  93. package/dist/plugin/theme/src/plugin/platform/cores/platform.d.ts +3 -0
  94. package/dist/plugin/theme/src/plugin/platform/index.d.ts +5 -0
  95. package/dist/plugin/theme/src/plugin/platform/types/index.d.ts +1 -0
  96. package/dist/plugin/theme/src/plugin/platform/types/platform.d.ts +13 -0
  97. package/dist/plugin/theme/src/plugin/theme/constants/theme.d.ts +16 -0
  98. package/dist/plugin/theme/src/plugin/theme/cores/theme.d.ts +3 -0
  99. package/dist/plugin/theme/src/plugin/theme/errors/easing-error.d.ts +6 -0
  100. package/dist/plugin/theme/src/plugin/theme/errors/unsupported-color-error.d.ts +2 -0
  101. package/dist/plugin/theme/src/plugin/theme/index.d.ts +5 -0
  102. package/dist/plugin/theme/src/plugin/theme/types/color.d.ts +17 -0
  103. package/dist/plugin/theme/src/plugin/theme/types/easing-syntax.d.ts +16 -0
  104. package/dist/plugin/theme/src/plugin/theme/types/index.d.ts +3 -0
  105. package/dist/plugin/theme/src/plugin/theme/types/theme.d.ts +24 -0
  106. package/dist/plugin/theme/src/plugin/theme/utils/parse-color.d.ts +2 -0
  107. package/dist/plugin/theme/src/plugin/theme/utils/parse-easing-function.d.ts +2 -0
  108. package/dist/plugin/theme/src/types/index.d.ts +1 -0
  109. package/dist/plugin/theme/src/types/native.d.ts +14 -0
  110. package/dist/plugin/theme/src/utils/assign.d.ts +1 -0
  111. package/dist/plugin/theme/src/utils/create-custom-error.d.ts +1 -0
  112. package/dist/src/plugin/app/constants/app.d.ts +13 -0
  113. package/dist/src/plugin/app/cores/app.d.ts +3 -0
  114. package/dist/src/plugin/app/errors/url-open-error.d.ts +2 -0
  115. package/dist/src/plugin/app/index.d.ts +5 -0
  116. package/dist/src/plugin/app/types/app.d.ts +54 -0
  117. package/dist/src/plugin/app/types/index.d.ts +1 -0
  118. package/dist/src/plugin/app/utils/event-listener-utils.d.ts +3 -0
  119. package/dist/src/plugin/app/utils/try-open-url.d.ts +1 -0
  120. package/dist/src/plugin/platform/cores/platform.d.ts +3 -0
  121. package/dist/src/plugin/platform/index.d.ts +5 -0
  122. package/dist/src/plugin/platform/types/index.d.ts +1 -0
  123. package/dist/src/plugin/platform/types/platform.d.ts +13 -0
  124. package/dist/src/plugin/theme/constants/theme.d.ts +16 -0
  125. package/dist/src/plugin/theme/cores/theme.d.ts +3 -0
  126. package/dist/src/plugin/theme/errors/easing-error.d.ts +6 -0
  127. package/dist/src/plugin/theme/errors/unsupported-color-error.d.ts +2 -0
  128. package/dist/src/plugin/theme/index.d.ts +5 -0
  129. package/dist/src/plugin/theme/types/color.d.ts +17 -0
  130. package/dist/src/plugin/theme/types/easing-syntax.d.ts +16 -0
  131. package/dist/src/plugin/theme/types/index.d.ts +3 -0
  132. package/dist/src/plugin/theme/types/theme.d.ts +24 -0
  133. package/dist/src/plugin/theme/utils/parse-color.d.ts +2 -0
  134. package/dist/src/plugin/theme/utils/parse-easing-function.d.ts +2 -0
  135. package/dist/src/types/index.d.ts +1 -5
  136. package/dist/src/types/native.d.ts +14 -0
  137. package/dist/src/utils/assign.d.ts +1 -0
  138. package/package.json +3 -2
  139. package/dist/src/types/app.d.ts +0 -44
  140. package/dist/src/types/color.d.ts +0 -17
  141. package/dist/src/utils/freeze-deep.d.ts +0 -1
  142. /package/dist/{src → plugin/app/src/plugin/app}/constants/app.d.ts +0 -0
  143. /package/dist/{src → plugin/app/src/plugin/app}/errors/url-open-error.d.ts +0 -0
  144. /package/dist/{src → plugin/app/src/plugin/app}/utils/try-open-url.d.ts +0 -0
  145. /package/dist/{src → plugin/app/src/plugin/theme}/errors/easing-error.d.ts +0 -0
  146. /package/dist/{src → plugin/app/src/plugin/theme}/errors/unsupported-color-error.d.ts +0 -0
package/README.md CHANGED
@@ -1,206 +1,36 @@
1
- # Native.App API Reference
1
+ # native-fn API Reference
2
+
3
+ ![NPM](https://nodei.co/npm/native-fn.png?downloads=true&downloadRank=true&stars=true)<br>
4
+ ![NPM Downloads](https://img.shields.io/npm/d18m/native-fn?style=flat&logo=npm&logoColor=%23CB3837&label=Download&color=%23CB3837&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Fnative-fn)
5
+ ![GitHub Repo stars](https://img.shields.io/github/stars/pjy0509/native-fn?style=flat&logo=github&logoColor=181717&label=Stars&color=181717&link=https%3A%2F%2Fgithub.com%2Fpjy0509%2Fnative-fn)
6
+ ![Static Badge](https://img.shields.io/badge/Typescript-8A2BE2?logo=typescript&color=000000)
2
7
 
3
8
  ## Overview
4
- Native.App provides a unified interface for opening native applications across different platforms with cross-platform compatibility.
5
9
 
6
10
  ---
7
-
8
- ## Interface
9
-
10
- ### App
11
- Main interface for native app operations.
12
-
13
- ```typescript
14
- interface App {
15
- open: (options: AppOpenOptions, target?: WindowProxy) => Promise<AppOpenState>;
16
- messenger: Messenger;
17
- }
11
+ ## Install
12
+ npm
13
+ ```bash
14
+ npm i native-fn
18
15
  ```
19
-
20
- ---
21
-
22
- ## Methods
23
-
24
- ### `Native.App.open()`
25
-
26
- Opens a native application with platform-specific configurations.
27
-
28
- #### Syntax
29
- ```typescript
30
- Native.App.open(options: AppOpenOptions, target?: WindowProxy): Promise<AppOpenState>
16
+ yarn
17
+ ```bash
18
+ yarn add native-fn
31
19
  ```
32
-
33
- #### Parameters
34
-
35
- | Parameter | Type | Required | Description |
36
- |-----------|------|----------|-------------|
37
- | `options` | `AppOpenOptions` | ✅ | Platform-specific app configuration |
38
- | `target` | `WindowProxy` | ❌ | Target window (default: current window) |
39
-
40
- #### Platform Options
41
-
42
- Each platform requires different configuration parameters:
43
-
44
- ##### Android
45
- ```typescript
46
- {
47
- [Native.Constant.OS.Android]: {
48
- scheme: string; // App URL scheme
49
- packageName: string; // Android package name
50
- }
51
- }
20
+ cdn
21
+ ```html
22
+ <script src='https://unpkg.com/native-fn'></script>
52
23
  ```
53
24
 
54
- ##### iOS
55
- ```typescript
56
- {
57
- [Native.Constant.OS.iOS]: {
58
- scheme: string; // App URL scheme
59
- packageName: string; // Bundle ID
60
- trackId?: string; // App Store track ID (optional)
61
- }
62
- }
63
- ```
64
-
65
- ##### Windows
66
- ```typescript
67
- {
68
- [Native.Constant.OS.Windows]: {
69
- scheme: string; // App URL scheme
70
- productId: string; // Microsoft Store product ID
71
- }
72
- }
73
- ```
74
-
75
- ##### macOS
76
- ```typescript
77
- {
78
- [Native.Constant.OS.MacOS]: {
79
- scheme: string; // App URL scheme
80
- packageName: string; // Bundle ID
81
- trackId?: string; // App Store track ID (optional)
82
- }
83
- }
84
- ```
85
-
86
- ---
87
-
88
- ## Examples
89
-
90
- ### Basic Usage
91
-
92
- Open Microsoft Excel across all platforms:
25
+ ## Interface
93
26
 
94
27
  ```typescript
95
- // Create a new tab for the app to open in
96
- const newTab: WindowProxy = window.open("about:blank");
97
-
98
- // Configure Excel for all platforms
99
- const excelConfig = {
100
- [Native.Constant.OS.Android]: {
101
- scheme: "excel://",
102
- packageName: "com.microsoft.office.excel",
103
- },
104
- [Native.Constant.OS.iOS]: {
105
- scheme: "excel://",
106
- packageName: "com.microsoft.Office.Excel",
107
- // trackId: "586683407", // Uncomment if needed
108
- },
109
- [Native.Constant.OS.Windows]: {
110
- scheme: "excel://",
111
- productId: "cfq7ttc0k5bf",
112
- },
113
- [Native.Constant.OS.MacOS]: {
114
- scheme: "excel://",
115
- packageName: "com.microsoft.Excel",
116
- // trackId: "462058435", // Uncomment if needed
117
- }
118
- };
119
-
120
- // Open Excel
121
- try {
122
- const result = await Native.App.open(excelConfig, newTab);
123
- console.log('Excel opened successfully:', result);
124
- } catch (error) {
125
- console.error('Failed to open Excel:', error);
28
+ interface Native {
29
+ App: App
126
30
  }
127
- ```
128
-
129
- ### Single Platform Example
130
-
131
- Open an app on a specific platform:
132
31
 
133
- ```typescript
134
- // Android only
135
- const androidConfig = {
136
- [Native.Constant.OS.Android]: {
137
- scheme: "myapp://",
138
- packageName: "com.example.myapp",
139
- }
140
- };
141
-
142
- await Native.App.open(androidConfig);
143
- ```
144
-
145
- ---
146
-
147
- ## Return Value
148
-
149
- Returns `Promise<AppOpenState>` with information about the app opening state.
150
-
151
- ---
152
-
153
- ## Error Handling
154
-
155
- The method may reject with errors in the following cases:
156
- - App is not installed on the device
157
- - Invalid configuration parameters
158
- - Platform not supported
159
- - Network connectivity issues
160
-
161
- ```typescript
162
- try {
163
- await Native.App.open(config);
164
- } catch (error) {
165
- if (error.code === 'APP_NOT_FOUND') {
166
- // Handle app not installed
167
- } else if (error.code === 'INVALID_CONFIG') {
168
- // Handle configuration error
169
- }
32
+ interface App {
33
+ open: (options: AppOpenOptions, target?: WindowProxy) => Promise<AppOpenState>;
34
+ messenger: Messenger;
170
35
  }
171
36
  ```
172
-
173
- ---
174
-
175
- ## Best Practices
176
-
177
- ### ✅ Do
178
- - Always provide configurations for all target platforms
179
- - Use `window.open("about:blank")` for better user experience
180
- - Handle errors gracefully with try-catch blocks
181
- - Test on all target platforms
182
-
183
- ### ❌ Don't
184
- - Hardcode platform detection in your application logic
185
- - Ignore error handling
186
- - Use deprecated package names or schemes
187
-
188
- ---
189
-
190
- ## Platform-Specific Notes
191
-
192
- ### Android
193
- - Package names follow reverse domain notation
194
- - Ensure the app supports the specified URL scheme
195
-
196
- ### iOS
197
- - Bundle IDs are case-sensitive
198
- - Track IDs are optional but recommended for App Store linking
199
-
200
- ### Windows
201
- - Product IDs can be found in the Microsoft Store URL
202
- - Some apps may require additional permissions
203
-
204
- ### macOS
205
- - Bundle IDs should match the app's Info.plist
206
- - Track IDs link to Mac App Store entries
package/dist/index.d.ts CHANGED
@@ -1,28 +1,4 @@
1
- import { AppOpenState, Messengers } from "./src/constants/app";
2
- import { OS, Devices, Engines } from "./src/constants/platform";
3
- import { Appearances } from "./src/constants/theme";
4
- export * from "./src/types";
5
- declare const _default: {
6
- Version: string;
7
- Constants: {
8
- Messengers: typeof Messengers;
9
- AppOpenState: typeof AppOpenState;
10
- Devices: typeof Devices;
11
- Engines: typeof Engines;
12
- OS: typeof OS;
13
- Appearances: typeof Appearances;
14
- };
15
- Errors: {
16
- URLOpenError: ErrorConstructor;
17
- UnsupportedColorError: ErrorConstructor;
18
- EasingError: ErrorConstructor;
19
- UnsupportedEasingFunctionError: ErrorConstructor;
20
- StepSyntaxError: ErrorConstructor;
21
- LinearSyntaxError: ErrorConstructor;
22
- CubicBezierSyntaxError: ErrorConstructor;
23
- };
24
- App: import("./src/types").App;
25
- Platform: import("./src/types").Platform;
26
- Theme: import("./src/types").Theme;
27
- };
28
- export default _default;
1
+ import { Native } from "./src/types";
2
+ export * from './src/types';
3
+ declare const Native: Native;
4
+ export default Native;