@intrig/plugin-react 0.0.2-2 → 0.0.2-4
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.cjs +76 -6
- package/dist/index.js +76 -6
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -44,8 +44,10 @@ class InternalGeneratorContext {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
function packageJsonTemplate() {
|
|
48
|
-
|
|
47
|
+
function packageJsonTemplate(ctx) {
|
|
48
|
+
var _ctx_rootDir;
|
|
49
|
+
const projectDir = (_ctx_rootDir = ctx.rootDir) != null ? _ctx_rootDir : process.cwd();
|
|
50
|
+
const packageJson = fsx__namespace.readJsonSync(path__namespace.resolve(projectDir, 'package.json'));
|
|
49
51
|
const json = pluginSdk.jsonLiteral(path__namespace.resolve('package.json'));
|
|
50
52
|
var _packageJson_devDependencies_typescript;
|
|
51
53
|
return json`
|
|
@@ -1433,6 +1435,72 @@ export function getAxiosInstance(key: string) {
|
|
|
1433
1435
|
`;
|
|
1434
1436
|
}
|
|
1435
1437
|
|
|
1438
|
+
function flushSyncUtilTemplate(ctx) {
|
|
1439
|
+
var _packageJson_dependencies, _packageJson_devDependencies, _packageJson_peerDependencies;
|
|
1440
|
+
const ts = pluginSdk.typescript(path__namespace.resolve('src', 'utils', 'flush-sync.ts'));
|
|
1441
|
+
var _ctx_rootDir;
|
|
1442
|
+
const projectDir = (_ctx_rootDir = ctx.rootDir) != null ? _ctx_rootDir : process.cwd();
|
|
1443
|
+
const packageJson = fsx__namespace.readJsonSync(path__namespace.resolve(projectDir, 'package.json'));
|
|
1444
|
+
// Check if react-dom is available at generation time
|
|
1445
|
+
const hasReactDom = !!(((_packageJson_dependencies = packageJson.dependencies) == null ? void 0 : _packageJson_dependencies['react-dom']) || ((_packageJson_devDependencies = packageJson.devDependencies) == null ? void 0 : _packageJson_devDependencies['react-dom']) || ((_packageJson_peerDependencies = packageJson.peerDependencies) == null ? void 0 : _packageJson_peerDependencies['react-dom']));
|
|
1446
|
+
if (hasReactDom) {
|
|
1447
|
+
// Generate DOM-compatible version
|
|
1448
|
+
return ts`/**
|
|
1449
|
+
* Platform-compatible flushSync utility
|
|
1450
|
+
*
|
|
1451
|
+
* This utility provides flushSync functionality for React DOM environments.
|
|
1452
|
+
* Uses the native flushSync from react-dom for synchronous updates.
|
|
1453
|
+
*/
|
|
1454
|
+
|
|
1455
|
+
import { flushSync as reactDomFlushSync } from 'react-dom';
|
|
1456
|
+
|
|
1457
|
+
/**
|
|
1458
|
+
* Cross-platform flushSync implementation
|
|
1459
|
+
*
|
|
1460
|
+
* Forces React to flush any pending updates synchronously.
|
|
1461
|
+
* Uses react-dom's native flushSync implementation.
|
|
1462
|
+
*
|
|
1463
|
+
* @param callback - The callback to execute synchronously
|
|
1464
|
+
*/
|
|
1465
|
+
export const flushSync = reactDomFlushSync;
|
|
1466
|
+
|
|
1467
|
+
/**
|
|
1468
|
+
* Check if we're running in a DOM environment
|
|
1469
|
+
* Always true when react-dom is available
|
|
1470
|
+
*/
|
|
1471
|
+
export const isDOMEnvironment = true;
|
|
1472
|
+
`;
|
|
1473
|
+
} else {
|
|
1474
|
+
// Generate React Native/non-DOM version
|
|
1475
|
+
return ts`/**
|
|
1476
|
+
* Platform-compatible flushSync utility
|
|
1477
|
+
*
|
|
1478
|
+
* This utility provides flushSync functionality for React Native and other non-DOM environments.
|
|
1479
|
+
* In React Native, we don't have the same concurrent rendering concerns,
|
|
1480
|
+
* so we execute the callback immediately.
|
|
1481
|
+
*/
|
|
1482
|
+
|
|
1483
|
+
/**
|
|
1484
|
+
* Cross-platform flushSync implementation
|
|
1485
|
+
*
|
|
1486
|
+
* Forces React to flush any pending updates synchronously.
|
|
1487
|
+
* In React Native, executes the callback immediately.
|
|
1488
|
+
*
|
|
1489
|
+
* @param callback - The callback to execute synchronously
|
|
1490
|
+
*/
|
|
1491
|
+
export const flushSync = (callback: () => void) => {
|
|
1492
|
+
callback();
|
|
1493
|
+
};
|
|
1494
|
+
|
|
1495
|
+
/**
|
|
1496
|
+
* Check if we're running in a DOM environment
|
|
1497
|
+
* Always false when react-dom is not available
|
|
1498
|
+
*/
|
|
1499
|
+
export const isDOMEnvironment = false;
|
|
1500
|
+
`;
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1436
1504
|
function providerMainTemplate(apisToSync) {
|
|
1437
1505
|
const ts = pluginSdk.typescript(path__namespace.resolve("src", "intrig-provider-main.tsx"));
|
|
1438
1506
|
return ts`// Re-export all provider functionality from modular templates
|
|
@@ -1895,7 +1963,7 @@ import {
|
|
|
1895
1963
|
} from './network-state';
|
|
1896
1964
|
import { Axios, AxiosResponse, isAxiosError } from 'axios';
|
|
1897
1965
|
import { ZodError, ZodSchema } from 'zod';
|
|
1898
|
-
import { flushSync } from '
|
|
1966
|
+
import { flushSync } from './utils/flush-sync';
|
|
1899
1967
|
import { createParser } from 'eventsource-parser';
|
|
1900
1968
|
|
|
1901
1969
|
import { Context, RequestType, GlobalState } from './intrig-context';
|
|
@@ -3114,7 +3182,7 @@ function handleComplexSchema(schema, imports) {
|
|
|
3114
3182
|
|
|
3115
3183
|
async function generateCode(ctx) {
|
|
3116
3184
|
// Root/project files
|
|
3117
|
-
await ctx.dump(packageJsonTemplate());
|
|
3185
|
+
await ctx.dump(packageJsonTemplate(ctx));
|
|
3118
3186
|
await ctx.dump(reactTsConfigTemplate());
|
|
3119
3187
|
await ctx.dump(reactSwcrcTemplate());
|
|
3120
3188
|
// Top-level src files
|
|
@@ -3126,6 +3194,7 @@ async function generateCode(ctx) {
|
|
|
3126
3194
|
await ctx.dump(reactMediaTypeUtilsTemplate());
|
|
3127
3195
|
await ctx.dump(typeUtilsTemplate());
|
|
3128
3196
|
await ctx.dump(intrigMiddlewareTemplate());
|
|
3197
|
+
await ctx.dump(flushSyncUtilTemplate(ctx));
|
|
3129
3198
|
// Provider modular files (placed under src)
|
|
3130
3199
|
await ctx.dump(providerMainTemplate(ctx.sources));
|
|
3131
3200
|
await ctx.dump(providerHooksTemplate());
|
|
@@ -3422,7 +3491,7 @@ Expose play/pause UI for long streams or admin tools.
|
|
|
3422
3491
|
import { use${pluginSdk.pascalCase(descriptor.name)} } from '@intrig/react/${descriptor.path}/client';
|
|
3423
3492
|
import { isPending, isSuccess, isError } from '@intrig/react';
|
|
3424
3493
|
import { useEffect, useState } from 'react';
|
|
3425
|
-
import { flushSync } from '
|
|
3494
|
+
import { flushSync } from '../utils/flush-sync';
|
|
3426
3495
|
|
|
3427
3496
|
function MyComponent() {
|
|
3428
3497
|
const [${respVar}, ${actionName}] = use${pluginSdk.pascalCase(descriptor.name)}({ clearOnUnmount: true });
|
|
@@ -4247,7 +4316,8 @@ function createPlugin() {
|
|
|
4247
4316
|
return {
|
|
4248
4317
|
name: 'intrig-binding',
|
|
4249
4318
|
version: '0.0.1',
|
|
4250
|
-
compat: '^0.0.15'
|
|
4319
|
+
compat: '^0.0.15',
|
|
4320
|
+
generator: 'react'
|
|
4251
4321
|
};
|
|
4252
4322
|
},
|
|
4253
4323
|
generate: generateCode,
|
package/dist/index.js
CHANGED
|
@@ -20,8 +20,10 @@ class InternalGeneratorContext {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
function packageJsonTemplate() {
|
|
24
|
-
|
|
23
|
+
function packageJsonTemplate(ctx) {
|
|
24
|
+
var _ctx_rootDir;
|
|
25
|
+
const projectDir = (_ctx_rootDir = ctx.rootDir) != null ? _ctx_rootDir : process.cwd();
|
|
26
|
+
const packageJson = fsx.readJsonSync(path.resolve(projectDir, 'package.json'));
|
|
25
27
|
const json = jsonLiteral(path.resolve('package.json'));
|
|
26
28
|
var _packageJson_devDependencies_typescript;
|
|
27
29
|
return json`
|
|
@@ -1409,6 +1411,72 @@ export function getAxiosInstance(key: string) {
|
|
|
1409
1411
|
`;
|
|
1410
1412
|
}
|
|
1411
1413
|
|
|
1414
|
+
function flushSyncUtilTemplate(ctx) {
|
|
1415
|
+
var _packageJson_dependencies, _packageJson_devDependencies, _packageJson_peerDependencies;
|
|
1416
|
+
const ts = typescript(path.resolve('src', 'utils', 'flush-sync.ts'));
|
|
1417
|
+
var _ctx_rootDir;
|
|
1418
|
+
const projectDir = (_ctx_rootDir = ctx.rootDir) != null ? _ctx_rootDir : process.cwd();
|
|
1419
|
+
const packageJson = fsx.readJsonSync(path.resolve(projectDir, 'package.json'));
|
|
1420
|
+
// Check if react-dom is available at generation time
|
|
1421
|
+
const hasReactDom = !!(((_packageJson_dependencies = packageJson.dependencies) == null ? void 0 : _packageJson_dependencies['react-dom']) || ((_packageJson_devDependencies = packageJson.devDependencies) == null ? void 0 : _packageJson_devDependencies['react-dom']) || ((_packageJson_peerDependencies = packageJson.peerDependencies) == null ? void 0 : _packageJson_peerDependencies['react-dom']));
|
|
1422
|
+
if (hasReactDom) {
|
|
1423
|
+
// Generate DOM-compatible version
|
|
1424
|
+
return ts`/**
|
|
1425
|
+
* Platform-compatible flushSync utility
|
|
1426
|
+
*
|
|
1427
|
+
* This utility provides flushSync functionality for React DOM environments.
|
|
1428
|
+
* Uses the native flushSync from react-dom for synchronous updates.
|
|
1429
|
+
*/
|
|
1430
|
+
|
|
1431
|
+
import { flushSync as reactDomFlushSync } from 'react-dom';
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* Cross-platform flushSync implementation
|
|
1435
|
+
*
|
|
1436
|
+
* Forces React to flush any pending updates synchronously.
|
|
1437
|
+
* Uses react-dom's native flushSync implementation.
|
|
1438
|
+
*
|
|
1439
|
+
* @param callback - The callback to execute synchronously
|
|
1440
|
+
*/
|
|
1441
|
+
export const flushSync = reactDomFlushSync;
|
|
1442
|
+
|
|
1443
|
+
/**
|
|
1444
|
+
* Check if we're running in a DOM environment
|
|
1445
|
+
* Always true when react-dom is available
|
|
1446
|
+
*/
|
|
1447
|
+
export const isDOMEnvironment = true;
|
|
1448
|
+
`;
|
|
1449
|
+
} else {
|
|
1450
|
+
// Generate React Native/non-DOM version
|
|
1451
|
+
return ts`/**
|
|
1452
|
+
* Platform-compatible flushSync utility
|
|
1453
|
+
*
|
|
1454
|
+
* This utility provides flushSync functionality for React Native and other non-DOM environments.
|
|
1455
|
+
* In React Native, we don't have the same concurrent rendering concerns,
|
|
1456
|
+
* so we execute the callback immediately.
|
|
1457
|
+
*/
|
|
1458
|
+
|
|
1459
|
+
/**
|
|
1460
|
+
* Cross-platform flushSync implementation
|
|
1461
|
+
*
|
|
1462
|
+
* Forces React to flush any pending updates synchronously.
|
|
1463
|
+
* In React Native, executes the callback immediately.
|
|
1464
|
+
*
|
|
1465
|
+
* @param callback - The callback to execute synchronously
|
|
1466
|
+
*/
|
|
1467
|
+
export const flushSync = (callback: () => void) => {
|
|
1468
|
+
callback();
|
|
1469
|
+
};
|
|
1470
|
+
|
|
1471
|
+
/**
|
|
1472
|
+
* Check if we're running in a DOM environment
|
|
1473
|
+
* Always false when react-dom is not available
|
|
1474
|
+
*/
|
|
1475
|
+
export const isDOMEnvironment = false;
|
|
1476
|
+
`;
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1412
1480
|
function providerMainTemplate(apisToSync) {
|
|
1413
1481
|
const ts = typescript(path.resolve("src", "intrig-provider-main.tsx"));
|
|
1414
1482
|
return ts`// Re-export all provider functionality from modular templates
|
|
@@ -1871,7 +1939,7 @@ import {
|
|
|
1871
1939
|
} from './network-state';
|
|
1872
1940
|
import { Axios, AxiosResponse, isAxiosError } from 'axios';
|
|
1873
1941
|
import { ZodError, ZodSchema } from 'zod';
|
|
1874
|
-
import { flushSync } from '
|
|
1942
|
+
import { flushSync } from './utils/flush-sync';
|
|
1875
1943
|
import { createParser } from 'eventsource-parser';
|
|
1876
1944
|
|
|
1877
1945
|
import { Context, RequestType, GlobalState } from './intrig-context';
|
|
@@ -3090,7 +3158,7 @@ function handleComplexSchema(schema, imports) {
|
|
|
3090
3158
|
|
|
3091
3159
|
async function generateCode(ctx) {
|
|
3092
3160
|
// Root/project files
|
|
3093
|
-
await ctx.dump(packageJsonTemplate());
|
|
3161
|
+
await ctx.dump(packageJsonTemplate(ctx));
|
|
3094
3162
|
await ctx.dump(reactTsConfigTemplate());
|
|
3095
3163
|
await ctx.dump(reactSwcrcTemplate());
|
|
3096
3164
|
// Top-level src files
|
|
@@ -3102,6 +3170,7 @@ async function generateCode(ctx) {
|
|
|
3102
3170
|
await ctx.dump(reactMediaTypeUtilsTemplate());
|
|
3103
3171
|
await ctx.dump(typeUtilsTemplate());
|
|
3104
3172
|
await ctx.dump(intrigMiddlewareTemplate());
|
|
3173
|
+
await ctx.dump(flushSyncUtilTemplate(ctx));
|
|
3105
3174
|
// Provider modular files (placed under src)
|
|
3106
3175
|
await ctx.dump(providerMainTemplate(ctx.sources));
|
|
3107
3176
|
await ctx.dump(providerHooksTemplate());
|
|
@@ -3398,7 +3467,7 @@ Expose play/pause UI for long streams or admin tools.
|
|
|
3398
3467
|
import { use${pascalCase(descriptor.name)} } from '@intrig/react/${descriptor.path}/client';
|
|
3399
3468
|
import { isPending, isSuccess, isError } from '@intrig/react';
|
|
3400
3469
|
import { useEffect, useState } from 'react';
|
|
3401
|
-
import { flushSync } from '
|
|
3470
|
+
import { flushSync } from '../utils/flush-sync';
|
|
3402
3471
|
|
|
3403
3472
|
function MyComponent() {
|
|
3404
3473
|
const [${respVar}, ${actionName}] = use${pascalCase(descriptor.name)}({ clearOnUnmount: true });
|
|
@@ -4223,7 +4292,8 @@ function createPlugin() {
|
|
|
4223
4292
|
return {
|
|
4224
4293
|
name: 'intrig-binding',
|
|
4225
4294
|
version: '0.0.1',
|
|
4226
|
-
compat: '^0.0.15'
|
|
4295
|
+
compat: '^0.0.15',
|
|
4296
|
+
generator: 'react'
|
|
4227
4297
|
};
|
|
4228
4298
|
},
|
|
4229
4299
|
generate: generateCode,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intrig/plugin-react",
|
|
3
|
-
"version": "0.0.2-
|
|
3
|
+
"version": "0.0.2-4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@intrig/plugin-sdk": "^0.0.2-
|
|
18
|
+
"@intrig/plugin-sdk": "^0.0.2-4",
|
|
19
19
|
"@swc/helpers": "~0.5.11"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|