@syntrologie/runtime-sdk 2.2.0-canary.13 → 2.2.0-canary.14
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/README.md +1 -1
- package/dist/{chunk-BBOM2MPC.js → chunk-GUDQECKY.js} +35 -4
- package/dist/chunk-GUDQECKY.js.map +7 -0
- package/dist/index.js +1 -1
- package/dist/react.js +1 -1
- package/dist/smart-canvas.esm.js +22 -22
- package/dist/smart-canvas.esm.js.map +3 -3
- package/dist/smart-canvas.js +33 -3
- package/dist/smart-canvas.js.map +2 -2
- package/dist/smart-canvas.min.js +23 -23
- package/dist/smart-canvas.min.js.map +3 -3
- package/dist/version.d.ts +1 -1
- package/package.json +11 -7
- package/scripts/syntroReactPlugin.mjs +113 -0
- package/dist/chunk-BBOM2MPC.js.map +0 -7
package/dist/version.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syntrologie/runtime-sdk",
|
|
3
|
-
"version": "2.2.0-canary.
|
|
3
|
+
"version": "2.2.0-canary.14",
|
|
4
4
|
"description": "Syntrologie Runtime SDK for web experimentation and analytics",
|
|
5
5
|
"license": "Proprietary",
|
|
6
6
|
"private": false,
|
|
@@ -35,12 +35,16 @@
|
|
|
35
35
|
"./cdn": {
|
|
36
36
|
"import": "./dist/smart-canvas.esm.js",
|
|
37
37
|
"require": "./dist/smart-canvas.js"
|
|
38
|
+
},
|
|
39
|
+
"./build-plugin": {
|
|
40
|
+
"import": "./scripts/syntroReactPlugin.mjs"
|
|
38
41
|
}
|
|
39
42
|
},
|
|
40
43
|
"files": [
|
|
41
44
|
"dist",
|
|
42
45
|
"schema",
|
|
43
46
|
"scripts/validate-config.mjs",
|
|
47
|
+
"scripts/syntroReactPlugin.mjs",
|
|
44
48
|
"CAPABILITIES.md"
|
|
45
49
|
],
|
|
46
50
|
"scripts": {
|
|
@@ -63,12 +67,12 @@
|
|
|
63
67
|
"@floating-ui/dom": "^1.7.5",
|
|
64
68
|
"@growthbook/growthbook": "~1.6.2",
|
|
65
69
|
"@growthbook/growthbook-react": "^1.6.4",
|
|
66
|
-
"@syntrologie/adapt-chatbot": "2.2.0-canary.
|
|
67
|
-
"@syntrologie/adapt-content": "2.2.0-canary.
|
|
68
|
-
"@syntrologie/adapt-faq": "2.2.0-canary.
|
|
69
|
-
"@syntrologie/adapt-gamification": "2.2.0-canary.
|
|
70
|
-
"@syntrologie/adapt-nav": "2.2.0-canary.
|
|
71
|
-
"@syntrologie/adapt-overlays": "2.2.0-canary.
|
|
70
|
+
"@syntrologie/adapt-chatbot": "2.2.0-canary.14",
|
|
71
|
+
"@syntrologie/adapt-content": "2.2.0-canary.14",
|
|
72
|
+
"@syntrologie/adapt-faq": "2.2.0-canary.14",
|
|
73
|
+
"@syntrologie/adapt-gamification": "2.2.0-canary.14",
|
|
74
|
+
"@syntrologie/adapt-nav": "2.2.0-canary.14",
|
|
75
|
+
"@syntrologie/adapt-overlays": "2.2.0-canary.14",
|
|
72
76
|
"posthog-js": "~1.302.2",
|
|
73
77
|
"zod": "^3.25.76"
|
|
74
78
|
},
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* syntroReactPlugin — esbuild plugin for shared React via SynOS
|
|
3
|
+
*
|
|
4
|
+
* Replaces `import { useState } from 'react'` (and react-dom, jsx-runtime)
|
|
5
|
+
* with lazy wrappers that resolve to SynOS.React / SynOS.ReactDOM at call
|
|
6
|
+
* time. This means:
|
|
7
|
+
* - Adaptive modules load and self-register without React being available
|
|
8
|
+
* - React resolves when components actually render
|
|
9
|
+
* - The runtime SDK sets SynOS.React at module scope before any render
|
|
10
|
+
*
|
|
11
|
+
* Used by: build-cdn.js, build-adaptives-only.js, editor-sdk/build.js
|
|
12
|
+
*/
|
|
13
|
+
export const syntroReactPlugin = {
|
|
14
|
+
name: 'syntro-react',
|
|
15
|
+
setup(build) {
|
|
16
|
+
build.onResolve({ filter: /^react(-dom)?(\/.*)?$/ }, (args) => ({
|
|
17
|
+
path: args.path,
|
|
18
|
+
namespace: 'syntro-react',
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
build.onLoad({ filter: /.*/, namespace: 'syntro-react' }, (args) => {
|
|
22
|
+
if (args.path === 'react/jsx-runtime' || args.path === 'react/jsx-dev-runtime') {
|
|
23
|
+
return {
|
|
24
|
+
contents: `
|
|
25
|
+
function _R() {
|
|
26
|
+
return (typeof SynOS !== 'undefined' && SynOS.React) || {};
|
|
27
|
+
}
|
|
28
|
+
function _jsx(type, props, key) {
|
|
29
|
+
var R = _R();
|
|
30
|
+
var p = props || {};
|
|
31
|
+
var c = p.children;
|
|
32
|
+
delete p.children;
|
|
33
|
+
if (key !== undefined) p.key = key;
|
|
34
|
+
return Array.isArray(c)
|
|
35
|
+
? R.createElement.apply(null, [type, p].concat(c))
|
|
36
|
+
: c !== undefined
|
|
37
|
+
? R.createElement(type, p, c)
|
|
38
|
+
: R.createElement(type, p);
|
|
39
|
+
}
|
|
40
|
+
export var jsx = _jsx;
|
|
41
|
+
export var jsxs = _jsx;
|
|
42
|
+
export var Fragment = _R().Fragment;
|
|
43
|
+
`,
|
|
44
|
+
loader: 'js',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (args.path === 'react') {
|
|
48
|
+
// Hooks and creation APIs are lazy function wrappers — they resolve
|
|
49
|
+
// SynOS.React at call time (during render), not at module load.
|
|
50
|
+
//
|
|
51
|
+
// Component types (Fragment, Suspense, etc.) are resolved at module
|
|
52
|
+
// evaluation via _R(). This is fine because the runtime SDK always
|
|
53
|
+
// loads before adaptive modules evaluate, so SynOS.React is set.
|
|
54
|
+
// ES module named exports can't be truly lazy (no getter support).
|
|
55
|
+
return {
|
|
56
|
+
contents: `
|
|
57
|
+
function _R() {
|
|
58
|
+
return (typeof SynOS !== 'undefined' && SynOS.React) || {};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Default export — lazy proxy for React.* access
|
|
62
|
+
export default new Proxy({}, { get: function(_, k) { return _R()[k]; } });
|
|
63
|
+
|
|
64
|
+
// Hooks — lazy function wrappers (resolve at call time)
|
|
65
|
+
export function useState() { return _R().useState.apply(null, arguments); }
|
|
66
|
+
export function useEffect() { return _R().useEffect.apply(null, arguments); }
|
|
67
|
+
export function useMemo() { return _R().useMemo.apply(null, arguments); }
|
|
68
|
+
export function useCallback() { return _R().useCallback.apply(null, arguments); }
|
|
69
|
+
export function useRef() { return _R().useRef.apply(null, arguments); }
|
|
70
|
+
export function useContext() { return _R().useContext.apply(null, arguments); }
|
|
71
|
+
export function useReducer() { return _R().useReducer.apply(null, arguments); }
|
|
72
|
+
export function useLayoutEffect() { return _R().useLayoutEffect.apply(null, arguments); }
|
|
73
|
+
export function useId() { return _R().useId.apply(null, arguments); }
|
|
74
|
+
|
|
75
|
+
// Creation APIs — lazy function wrappers
|
|
76
|
+
export function createElement() { return _R().createElement.apply(null, arguments); }
|
|
77
|
+
export function createContext() { return _R().createContext.apply(null, arguments); }
|
|
78
|
+
export function forwardRef() { return _R().forwardRef.apply(null, arguments); }
|
|
79
|
+
export function memo() { return _R().memo.apply(null, arguments); }
|
|
80
|
+
export function lazy() { return _R().lazy.apply(null, arguments); }
|
|
81
|
+
export function isValidElement() { return _R().isValidElement.apply(null, arguments); }
|
|
82
|
+
export function cloneElement() { return _R().cloneElement.apply(null, arguments); }
|
|
83
|
+
|
|
84
|
+
// Component types — resolved at module eval (runtime loads first)
|
|
85
|
+
var _r = _R();
|
|
86
|
+
export var Fragment = _r.Fragment;
|
|
87
|
+
export var Suspense = _r.Suspense;
|
|
88
|
+
export var Children = _r.Children;
|
|
89
|
+
export var Component = _r.Component;
|
|
90
|
+
export var PureComponent = _r.PureComponent;
|
|
91
|
+
`,
|
|
92
|
+
loader: 'js',
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (args.path === 'react-dom' || args.path.startsWith('react-dom/')) {
|
|
96
|
+
return {
|
|
97
|
+
contents: `
|
|
98
|
+
function _RD() {
|
|
99
|
+
return (typeof SynOS !== 'undefined' && SynOS.ReactDOM) || {};
|
|
100
|
+
}
|
|
101
|
+
export default new Proxy({}, { get: function(_, k) { return _RD()[k]; } });
|
|
102
|
+
export function createRoot() { return _RD().createRoot.apply(null, arguments); }
|
|
103
|
+
export function hydrateRoot() { return _RD().hydrateRoot.apply(null, arguments); }
|
|
104
|
+
export function createPortal() { return _RD().createPortal.apply(null, arguments); }
|
|
105
|
+
export function flushSync() { return _RD().flushSync.apply(null, arguments); }
|
|
106
|
+
`,
|
|
107
|
+
loader: 'js',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return { contents: 'export default {};', loader: 'js' };
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
};
|