@apps-in-toss/plugins 0.0.39 → 1.0.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.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { BedrockPluginCore } from '@react-native-bedrock/plugin-core';
1
+ import { GranitePluginCore } from '@granite-js/plugin-core';
2
2
  import typia, { tags } from 'typia';
3
3
 
4
4
  type PermissionReadWrite = 'read' | 'write';
@@ -49,13 +49,15 @@ interface AppsInTossPluginOptions {
49
49
  type BridgeTheme = 'basic' | 'inverted';
50
50
  declare const validateAppInTossPluginOptions: (input: unknown) => typia.IValidation<AppsInTossPluginOptions>;
51
51
 
52
- declare function appsInTossEsbuildConfig(envScript: string): BedrockPluginCore;
53
- declare function appsInTossMetroConfig(envScriptPath: string): BedrockPluginCore;
54
- declare function appsInTossAppJson(options: Pick<AppsInTossPluginOptions, 'permissions'>): Promise<BedrockPluginCore>;
55
- declare function appsInTossPostNotice(): BedrockPluginCore;
56
- declare function appsInToss(options: AppsInTossPluginOptions): (BedrockPluginCore | Promise<BedrockPluginCore>)[];
52
+ declare function withAppsInTossCommon(plugins: (GranitePluginCore | Promise<GranitePluginCore>)[], options: AppsInTossPluginOptions & {
53
+ root: string;
54
+ deploymentId: string;
55
+ reactNativeBasePath?: string;
56
+ exposePath: string;
57
+ }): (GranitePluginCore | Promise<GranitePluginCore>)[];
58
+ declare function appsInToss(options: AppsInTossPluginOptions): (GranitePluginCore | Promise<GranitePluginCore>)[];
57
59
 
58
- declare function analytics(): BedrockPluginCore;
60
+ declare function analytics(): GranitePluginCore;
59
61
 
60
62
  interface AppsInTossBuildMetadata {
61
63
  runtimeVersion: string;
@@ -95,10 +97,46 @@ declare function setupRuntimeSetupScript(config: Pick<AppsInTossPluginOptions, '
95
97
  contents: string;
96
98
  path: string;
97
99
  };
100
+ declare function setupHostRuntimeSetupScript(metadata: {
101
+ deploymentId: string;
102
+ }): {
103
+ contents: string;
104
+ path: string;
105
+ };
106
+ declare function getRuntimeSetupScript<T extends object>(metadata: T, identifier: string): string;
98
107
 
99
108
  declare function collectDependencyVersions(rootDir: string): Promise<{
100
109
  dependencies: Record<string, string>;
101
110
  devDependencies: Record<string, string>;
102
111
  }>;
103
112
 
104
- export { type AppManifest, type AppsInTossPluginOptions, type BridgeTheme, type BuildResult, type CreateArtifactOptions, type Permission, analytics, appsInToss, appsInTossAppJson, appsInTossEsbuildConfig, appsInTossMetroConfig, appsInTossPostNotice, collectDependencyVersions, createArtifact, setupRuntimeSetupScript, validateAppInTossPluginOptions, validateAppManifest, validateZip };
113
+ declare function appsInTossAppJson(options: Pick<AppsInTossPluginOptions, 'permissions'>): Promise<GranitePluginCore>;
114
+
115
+ declare function appsInTossCreateArtifact(deploymentId: string): GranitePluginCore;
116
+
117
+ declare function appsInTossEsbuildConfig(envScript: string): GranitePluginCore;
118
+ declare function appsInTossMetroConfig(envScriptPath: string): GranitePluginCore;
119
+
120
+ /**
121
+ * React Native 번들을 포함하는 환경(Shared, 혹은 Metro single bundle) 내에서 React Native 모듈을 평가하기 때문에,
122
+ * `NativeModules` 접근 이전에 `nativeModuleProxy`를 오버라이드 할 수 있음.
123
+ */
124
+ declare const nativeModuleProxyContent = "\n(function () {\n global.nativeModuleProxy = new Proxy(global.nativeModuleProxy, {\n get: function (target, name) {\n if (name === 'GraniteModule') {\n return target['BedrockModule'] || target[name];\n }\n\n if (name === 'GraniteCoreModule') {\n return target['BedrockCoreModule'] || target[name];\n }\n\n return target[name];\n }\n });\n\n global.__nativeModuleProxyConfigured = true;\n})(\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof global !== 'undefined'\n ? global\n : typeof window !== 'undefined'\n ? window\n : this\n);\n";
125
+ /**
126
+ * Remote 번들에서는 Host 번들에서 React Native를 참조하므로, `NativeModules` 평가 이전에 `nativeModuleProxy`를 오버라이드 할 수 없다.
127
+ * 따라서 React Native 모듈 객체에 대한 프록시를 생성하여 `TurboModuleRegistry` 동작을 오버라이드 하도록 한다.
128
+ *
129
+ * 단, `nativeModuleProxy` 오버라이드 코드가 구성된 런타임인 경우 해당 과정은 건너뛰도록 분기 처리한다.
130
+ */
131
+ declare const reactNativeModuleProxyContent = "\n(function (global) {\n if (global.__nativeModuleProxyConfigured) {\n return;\n }\n\n function getCustomTurboModuleRegistry(registry) {\n var remappedModules = {\n 'GraniteModule': 'BedrockModule',\n 'GraniteCoreModule': 'BedrockCoreModule',\n };\n\n return {\n get: function (name) {\n var mod;\n var remappedName = remappedModules[name];\n\n if (remappedName) {\n mod = registry.get(remappedName);\n }\n\n return mod || registry.get(name);\n },\n getEnforcing: function (name) {\n var mod;\n var remappedName = remappedModules[name];\n\n if (remappedName) {\n mod = registry.get(remappedName);\n }\n\n return mod || registry.getEnforcing(name);\n }\n };\n }\n\n function createReactNativeProxy(reactNative) {\n return new Proxy(reactNative, {\n get: function (target, name) {\n var origin = target[name];\n return name === 'TurboModuleRegistry' ? getCustomTurboModuleRegistry(origin) : origin;\n }\n });\n }\n\n var reactNative;\n\n if (typeof global.__MICRO_FRONTEND__ !== 'undefined') {\n var mod = global.__MICRO_FRONTEND__.__SHARED__['react-native'];\n reactNative = mod && mod.get();\n }\n\n if (reactNative == null && typeof __bedrock_require__ === 'function') {\n reactNative = global.__bedrock_require__('react-native');\n }\n\n if (reactNative == null) {\n throw new Error('cannot get react-native in the global registry');\n }\n\n global.__reactNativeProxy = createReactNativeProxy(reactNative);\n global.__MICRO_FRONTEND__.__SHARED__['react-native'] = {\n get: function () {\n return global.__reactNativeProxy;\n },\n loaded: true,\n };\n})(\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof global !== 'undefined'\n ? global\n : typeof window !== 'undefined'\n ? window\n : this\n);\n";
132
+ declare function bedrockCompat({ isHost }: {
133
+ isHost: boolean;
134
+ }): GranitePluginCore;
135
+
136
+ declare function appsInTossDevServer(options: Pick<AppsInTossPluginOptions, 'permissions'>): GranitePluginCore;
137
+
138
+ declare function appsInTossPostNotice(): GranitePluginCore;
139
+
140
+ declare function requireMicroFrontendRuntime(): GranitePluginCore;
141
+
142
+ export { type AppManifest, type AppsInTossPluginOptions, type BridgeTheme, type BuildResult, type CreateArtifactOptions, type Permission, analytics, appsInToss, appsInTossAppJson, appsInTossCreateArtifact, appsInTossDevServer, appsInTossEsbuildConfig, appsInTossMetroConfig, appsInTossPostNotice, bedrockCompat, collectDependencyVersions, createArtifact, getRuntimeSetupScript, nativeModuleProxyContent, reactNativeModuleProxyContent, requireMicroFrontendRuntime, setupHostRuntimeSetupScript, setupRuntimeSetupScript, validateAppInTossPluginOptions, validateAppManifest, validateZip, withAppsInTossCommon };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BedrockPluginCore } from '@react-native-bedrock/plugin-core';
1
+ import { GranitePluginCore } from '@granite-js/plugin-core';
2
2
  import typia, { tags } from 'typia';
3
3
 
4
4
  type PermissionReadWrite = 'read' | 'write';
@@ -49,13 +49,15 @@ interface AppsInTossPluginOptions {
49
49
  type BridgeTheme = 'basic' | 'inverted';
50
50
  declare const validateAppInTossPluginOptions: (input: unknown) => typia.IValidation<AppsInTossPluginOptions>;
51
51
 
52
- declare function appsInTossEsbuildConfig(envScript: string): BedrockPluginCore;
53
- declare function appsInTossMetroConfig(envScriptPath: string): BedrockPluginCore;
54
- declare function appsInTossAppJson(options: Pick<AppsInTossPluginOptions, 'permissions'>): Promise<BedrockPluginCore>;
55
- declare function appsInTossPostNotice(): BedrockPluginCore;
56
- declare function appsInToss(options: AppsInTossPluginOptions): (BedrockPluginCore | Promise<BedrockPluginCore>)[];
52
+ declare function withAppsInTossCommon(plugins: (GranitePluginCore | Promise<GranitePluginCore>)[], options: AppsInTossPluginOptions & {
53
+ root: string;
54
+ deploymentId: string;
55
+ reactNativeBasePath?: string;
56
+ exposePath: string;
57
+ }): (GranitePluginCore | Promise<GranitePluginCore>)[];
58
+ declare function appsInToss(options: AppsInTossPluginOptions): (GranitePluginCore | Promise<GranitePluginCore>)[];
57
59
 
58
- declare function analytics(): BedrockPluginCore;
60
+ declare function analytics(): GranitePluginCore;
59
61
 
60
62
  interface AppsInTossBuildMetadata {
61
63
  runtimeVersion: string;
@@ -95,10 +97,46 @@ declare function setupRuntimeSetupScript(config: Pick<AppsInTossPluginOptions, '
95
97
  contents: string;
96
98
  path: string;
97
99
  };
100
+ declare function setupHostRuntimeSetupScript(metadata: {
101
+ deploymentId: string;
102
+ }): {
103
+ contents: string;
104
+ path: string;
105
+ };
106
+ declare function getRuntimeSetupScript<T extends object>(metadata: T, identifier: string): string;
98
107
 
99
108
  declare function collectDependencyVersions(rootDir: string): Promise<{
100
109
  dependencies: Record<string, string>;
101
110
  devDependencies: Record<string, string>;
102
111
  }>;
103
112
 
104
- export { type AppManifest, type AppsInTossPluginOptions, type BridgeTheme, type BuildResult, type CreateArtifactOptions, type Permission, analytics, appsInToss, appsInTossAppJson, appsInTossEsbuildConfig, appsInTossMetroConfig, appsInTossPostNotice, collectDependencyVersions, createArtifact, setupRuntimeSetupScript, validateAppInTossPluginOptions, validateAppManifest, validateZip };
113
+ declare function appsInTossAppJson(options: Pick<AppsInTossPluginOptions, 'permissions'>): Promise<GranitePluginCore>;
114
+
115
+ declare function appsInTossCreateArtifact(deploymentId: string): GranitePluginCore;
116
+
117
+ declare function appsInTossEsbuildConfig(envScript: string): GranitePluginCore;
118
+ declare function appsInTossMetroConfig(envScriptPath: string): GranitePluginCore;
119
+
120
+ /**
121
+ * React Native 번들을 포함하는 환경(Shared, 혹은 Metro single bundle) 내에서 React Native 모듈을 평가하기 때문에,
122
+ * `NativeModules` 접근 이전에 `nativeModuleProxy`를 오버라이드 할 수 있음.
123
+ */
124
+ declare const nativeModuleProxyContent = "\n(function () {\n global.nativeModuleProxy = new Proxy(global.nativeModuleProxy, {\n get: function (target, name) {\n if (name === 'GraniteModule') {\n return target['BedrockModule'] || target[name];\n }\n\n if (name === 'GraniteCoreModule') {\n return target['BedrockCoreModule'] || target[name];\n }\n\n return target[name];\n }\n });\n\n global.__nativeModuleProxyConfigured = true;\n})(\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof global !== 'undefined'\n ? global\n : typeof window !== 'undefined'\n ? window\n : this\n);\n";
125
+ /**
126
+ * Remote 번들에서는 Host 번들에서 React Native를 참조하므로, `NativeModules` 평가 이전에 `nativeModuleProxy`를 오버라이드 할 수 없다.
127
+ * 따라서 React Native 모듈 객체에 대한 프록시를 생성하여 `TurboModuleRegistry` 동작을 오버라이드 하도록 한다.
128
+ *
129
+ * 단, `nativeModuleProxy` 오버라이드 코드가 구성된 런타임인 경우 해당 과정은 건너뛰도록 분기 처리한다.
130
+ */
131
+ declare const reactNativeModuleProxyContent = "\n(function (global) {\n if (global.__nativeModuleProxyConfigured) {\n return;\n }\n\n function getCustomTurboModuleRegistry(registry) {\n var remappedModules = {\n 'GraniteModule': 'BedrockModule',\n 'GraniteCoreModule': 'BedrockCoreModule',\n };\n\n return {\n get: function (name) {\n var mod;\n var remappedName = remappedModules[name];\n\n if (remappedName) {\n mod = registry.get(remappedName);\n }\n\n return mod || registry.get(name);\n },\n getEnforcing: function (name) {\n var mod;\n var remappedName = remappedModules[name];\n\n if (remappedName) {\n mod = registry.get(remappedName);\n }\n\n return mod || registry.getEnforcing(name);\n }\n };\n }\n\n function createReactNativeProxy(reactNative) {\n return new Proxy(reactNative, {\n get: function (target, name) {\n var origin = target[name];\n return name === 'TurboModuleRegistry' ? getCustomTurboModuleRegistry(origin) : origin;\n }\n });\n }\n\n var reactNative;\n\n if (typeof global.__MICRO_FRONTEND__ !== 'undefined') {\n var mod = global.__MICRO_FRONTEND__.__SHARED__['react-native'];\n reactNative = mod && mod.get();\n }\n\n if (reactNative == null && typeof __bedrock_require__ === 'function') {\n reactNative = global.__bedrock_require__('react-native');\n }\n\n if (reactNative == null) {\n throw new Error('cannot get react-native in the global registry');\n }\n\n global.__reactNativeProxy = createReactNativeProxy(reactNative);\n global.__MICRO_FRONTEND__.__SHARED__['react-native'] = {\n get: function () {\n return global.__reactNativeProxy;\n },\n loaded: true,\n };\n})(\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof global !== 'undefined'\n ? global\n : typeof window !== 'undefined'\n ? window\n : this\n);\n";
132
+ declare function bedrockCompat({ isHost }: {
133
+ isHost: boolean;
134
+ }): GranitePluginCore;
135
+
136
+ declare function appsInTossDevServer(options: Pick<AppsInTossPluginOptions, 'permissions'>): GranitePluginCore;
137
+
138
+ declare function appsInTossPostNotice(): GranitePluginCore;
139
+
140
+ declare function requireMicroFrontendRuntime(): GranitePluginCore;
141
+
142
+ export { type AppManifest, type AppsInTossPluginOptions, type BridgeTheme, type BuildResult, type CreateArtifactOptions, type Permission, analytics, appsInToss, appsInTossAppJson, appsInTossCreateArtifact, appsInTossDevServer, appsInTossEsbuildConfig, appsInTossMetroConfig, appsInTossPostNotice, bedrockCompat, collectDependencyVersions, createArtifact, getRuntimeSetupScript, nativeModuleProxyContent, reactNativeModuleProxyContent, requireMicroFrontendRuntime, setupHostRuntimeSetupScript, setupRuntimeSetupScript, validateAppInTossPluginOptions, validateAppManifest, validateZip, withAppsInTossCommon };