@syntrologie/runtime-sdk 2.2.0-canary.13 → 2.2.0-canary.15
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-ZHIFNJPT.js} +70 -11
- package/dist/chunk-ZHIFNJPT.js.map +7 -0
- package/dist/index.js +1 -1
- package/dist/react.js +1 -1
- package/dist/smart-canvas.esm.js +39 -39
- package/dist/smart-canvas.esm.js.map +3 -3
- package/dist/smart-canvas.js +66 -9
- package/dist/smart-canvas.js.map +3 -3
- package/dist/smart-canvas.min.js +39 -39
- package/dist/smart-canvas.min.js.map +3 -3
- package/dist/version.d.ts +1 -1
- package/dist/widgets/WidgetRegistry.d.ts +10 -0
- package/package.json +11 -7
- package/scripts/syntroReactPlugin.mjs +113 -0
- package/dist/chunk-BBOM2MPC.js.map +0 -7
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smart Canvas Runtime SDK
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Runtime SDK (React + Shadow DOM)
|
|
4
4
|
|
|
5
5
|
The SDK ships a framework-agnostic `<smart-canvas>` custom element with an **open shadow root**. We render everything with React, but the canvas is encapsulated so host Tailwind configs, resets, or stacking contexts can't break the UI.
|
|
6
6
|
|
|
@@ -1858,8 +1858,8 @@ var AppRegistry = class {
|
|
|
1858
1858
|
if (!registration) {
|
|
1859
1859
|
throw new Error(`App not registered: ${appId}`);
|
|
1860
1860
|
}
|
|
1861
|
-
if (registration.state === "active") {
|
|
1862
|
-
console.warn(`[AppRegistry] App already
|
|
1861
|
+
if (registration.state === "active" || registration.state === "activating") {
|
|
1862
|
+
console.warn(`[AppRegistry] App already ${registration.state}: ${appId}`);
|
|
1863
1863
|
return;
|
|
1864
1864
|
}
|
|
1865
1865
|
if (!this.runtime) {
|
|
@@ -2091,7 +2091,7 @@ function getAntiFlickerSnippet(config = {}) {
|
|
|
2091
2091
|
}
|
|
2092
2092
|
|
|
2093
2093
|
// src/version.ts
|
|
2094
|
-
var SDK_VERSION = "2.2.0-canary.
|
|
2094
|
+
var SDK_VERSION = "2.2.0-canary.15";
|
|
2095
2095
|
|
|
2096
2096
|
// src/types.ts
|
|
2097
2097
|
var SDK_SCHEMA_VERSION = "2.0";
|
|
@@ -3125,26 +3125,33 @@ function useDecision(strategy, defaultValue) {
|
|
|
3125
3125
|
}
|
|
3126
3126
|
|
|
3127
3127
|
// src/components/TileCard.tsx
|
|
3128
|
-
import { useCallback as useCallback2, useEffect as useEffect5, useRef as useRef3, useState as useState4 } from "react";
|
|
3128
|
+
import { useCallback as useCallback2, useEffect as useEffect5, useReducer, useRef as useRef3, useState as useState4 } from "react";
|
|
3129
3129
|
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
3130
3130
|
function WidgetMount({ widgetId, props }) {
|
|
3131
|
+
var _a2;
|
|
3131
3132
|
const runtime3 = useRuntime();
|
|
3132
3133
|
const containerRef = useRef3(null);
|
|
3133
3134
|
const handleRef = useRef3(null);
|
|
3134
3135
|
const registry = runtime3 == null ? void 0 : runtime3.widgets;
|
|
3136
|
+
const widgetAvailable = (_a2 = registry == null ? void 0 : registry.has(widgetId)) != null ? _a2 : false;
|
|
3137
|
+
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
3135
3138
|
useEffect5(() => {
|
|
3136
|
-
if (!
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3139
|
+
if (!registry || widgetAvailable) return;
|
|
3140
|
+
return registry.subscribe((event) => {
|
|
3141
|
+
if (event.type === "registered" && event.widgetId === widgetId) {
|
|
3142
|
+
forceUpdate();
|
|
3143
|
+
}
|
|
3144
|
+
});
|
|
3145
|
+
}, [registry, widgetId, widgetAvailable]);
|
|
3146
|
+
useEffect5(() => {
|
|
3147
|
+
if (!containerRef.current || !registry || !widgetAvailable) return;
|
|
3141
3148
|
const handle = registry.mount(widgetId, containerRef.current, props);
|
|
3142
3149
|
handleRef.current = handle;
|
|
3143
3150
|
return () => {
|
|
3144
3151
|
handle.unmount();
|
|
3145
3152
|
handleRef.current = null;
|
|
3146
3153
|
};
|
|
3147
|
-
}, [registry, widgetId, props]);
|
|
3154
|
+
}, [registry, widgetId, props, widgetAvailable]);
|
|
3148
3155
|
if (!registry || !registry.has(widgetId)) {
|
|
3149
3156
|
return /* @__PURE__ */ jsxs2(
|
|
3150
3157
|
"div",
|
|
@@ -4203,12 +4210,22 @@ function decodeParam(paramName) {
|
|
|
4203
4210
|
var _cachedSource;
|
|
4204
4211
|
var _cachedConf;
|
|
4205
4212
|
function getEditorSource() {
|
|
4213
|
+
var _a2;
|
|
4206
4214
|
if (_cachedSource === void 0) {
|
|
4207
4215
|
const globalParams = typeof window !== "undefined" ? window.__SYNTRO_EDITOR_PARAMS__ : null;
|
|
4208
4216
|
if (globalParams == null ? void 0 : globalParams.token) {
|
|
4209
4217
|
_cachedSource = { token: globalParams.token, api_base: globalParams.apiBase || "" };
|
|
4218
|
+
console.log(
|
|
4219
|
+
`[DIAG] getEditorSource: from __SYNTRO_EDITOR_PARAMS__ (token=${_cachedSource.token.slice(0, 15)}...)`
|
|
4220
|
+
);
|
|
4210
4221
|
} else {
|
|
4211
4222
|
_cachedSource = decodeParam("editor_source");
|
|
4223
|
+
console.log(
|
|
4224
|
+
`[DIAG] getEditorSource: from URL param \u2192 ${_cachedSource ? `token=${(_a2 = _cachedSource.token) == null ? void 0 : _a2.slice(0, 15)}...` : "NULL"}`
|
|
4225
|
+
);
|
|
4226
|
+
if (!_cachedSource && typeof window !== "undefined") {
|
|
4227
|
+
console.log(`[DIAG] getEditorSource: URL search = ${window.location.search.slice(0, 200)}`);
|
|
4228
|
+
}
|
|
4212
4229
|
}
|
|
4213
4230
|
}
|
|
4214
4231
|
return _cachedSource;
|
|
@@ -4223,8 +4240,12 @@ function getEditorConf() {
|
|
|
4223
4240
|
syntro_token: globalParams.syntroToken,
|
|
4224
4241
|
workspace_id: globalParams.workspaceId
|
|
4225
4242
|
};
|
|
4243
|
+
console.log(`[DIAG] getEditorConf: from __SYNTRO_EDITOR_PARAMS__ (mode=${_cachedConf.mode})`);
|
|
4226
4244
|
} else {
|
|
4227
4245
|
_cachedConf = decodeParam("editor_conf");
|
|
4246
|
+
console.log(
|
|
4247
|
+
`[DIAG] getEditorConf: from URL param \u2192 ${_cachedConf ? `mode=${_cachedConf.mode}` : "NULL"}`
|
|
4248
|
+
);
|
|
4228
4249
|
}
|
|
4229
4250
|
}
|
|
4230
4251
|
return _cachedConf;
|
|
@@ -8236,6 +8257,7 @@ var WidgetRegistry = class {
|
|
|
8236
8257
|
__publicField(this, "mountedWidgets", /* @__PURE__ */ new Map());
|
|
8237
8258
|
__publicField(this, "mountIdCounter", 0);
|
|
8238
8259
|
__publicField(this, "runtimeRef");
|
|
8260
|
+
__publicField(this, "listeners", /* @__PURE__ */ new Set());
|
|
8239
8261
|
}
|
|
8240
8262
|
/**
|
|
8241
8263
|
* Bind a runtime reference so it can be injected into widget mount() calls.
|
|
@@ -8266,6 +8288,7 @@ var WidgetRegistry = class {
|
|
|
8266
8288
|
source,
|
|
8267
8289
|
metadata
|
|
8268
8290
|
});
|
|
8291
|
+
this.notify({ type: "registered", widgetId: id });
|
|
8269
8292
|
}
|
|
8270
8293
|
/**
|
|
8271
8294
|
* Unregister a widget.
|
|
@@ -8283,6 +8306,7 @@ var WidgetRegistry = class {
|
|
|
8283
8306
|
return false;
|
|
8284
8307
|
}
|
|
8285
8308
|
this.widgets.delete(id);
|
|
8309
|
+
this.notify({ type: "unregistered", widgetId: id });
|
|
8286
8310
|
return true;
|
|
8287
8311
|
}
|
|
8288
8312
|
/**
|
|
@@ -8390,6 +8414,24 @@ var WidgetRegistry = class {
|
|
|
8390
8414
|
(registration) => registration.source === source
|
|
8391
8415
|
);
|
|
8392
8416
|
}
|
|
8417
|
+
/**
|
|
8418
|
+
* Subscribe to widget registration changes.
|
|
8419
|
+
*/
|
|
8420
|
+
subscribe(callback) {
|
|
8421
|
+
this.listeners.add(callback);
|
|
8422
|
+
return () => {
|
|
8423
|
+
this.listeners.delete(callback);
|
|
8424
|
+
};
|
|
8425
|
+
}
|
|
8426
|
+
notify(event) {
|
|
8427
|
+
for (const listener of this.listeners) {
|
|
8428
|
+
try {
|
|
8429
|
+
listener(event);
|
|
8430
|
+
} catch (error2) {
|
|
8431
|
+
console.error("[WidgetRegistry] Listener error:", error2);
|
|
8432
|
+
}
|
|
8433
|
+
}
|
|
8434
|
+
}
|
|
8393
8435
|
/**
|
|
8394
8436
|
* Clean up all mounted widgets.
|
|
8395
8437
|
*/
|
|
@@ -8906,7 +8948,15 @@ async function init(options) {
|
|
|
8906
8948
|
const auditMode = isAuditMode();
|
|
8907
8949
|
const reviewMode = isReviewMode();
|
|
8908
8950
|
const sdkMode = editorMode ? "editor" : auditMode ? "audit" : reviewMode ? "review" : null;
|
|
8951
|
+
console.log(
|
|
8952
|
+
`[DIAG] Mode detection: editor=${editorMode}, audit=${auditMode}, review=${reviewMode}, sdkMode=${sdkMode}`
|
|
8953
|
+
);
|
|
8954
|
+
console.log(`[DIAG] editorSource:`, getEditorSource());
|
|
8955
|
+
console.log(`[DIAG] editorConf:`, getEditorConf());
|
|
8909
8956
|
debug("Syntro Bootstrap", "SDK mode:", sdkMode != null ? sdkMode : "normal");
|
|
8957
|
+
console.log(
|
|
8958
|
+
`[DIAG] Token resolution: options.token=${options.token ? options.token.slice(0, 15) + "..." : "null"}`
|
|
8959
|
+
);
|
|
8910
8960
|
let resolvedToken = options.token;
|
|
8911
8961
|
if (!resolvedToken && sdkMode) {
|
|
8912
8962
|
const conf = getEditorConf();
|
|
@@ -9045,15 +9095,24 @@ async function init(options) {
|
|
|
9045
9095
|
debug("Syntro Bootstrap", "Global SynOS object exposed");
|
|
9046
9096
|
}
|
|
9047
9097
|
const registeredApps = (_e = (_d = (_c = runtime3.apps).list) == null ? void 0 : _d.call(_c)) != null ? _e : [];
|
|
9098
|
+
console.log(
|
|
9099
|
+
`[DIAG] Activation loop: ${registeredApps.length} apps in registry:`,
|
|
9100
|
+
registeredApps.map((a) => `${a.manifest.id}(${a.state})`).join(", ")
|
|
9101
|
+
);
|
|
9048
9102
|
for (const app of registeredApps) {
|
|
9049
9103
|
if (app.state === "registered") {
|
|
9050
9104
|
try {
|
|
9051
9105
|
await runtime3.apps.activate(app.manifest.id);
|
|
9106
|
+
console.log(
|
|
9107
|
+
`[DIAG] Activated: ${app.manifest.id} \u2192 widgets: [${runtime3.widgets.list().join(", ")}]`
|
|
9108
|
+
);
|
|
9052
9109
|
} catch (err) {
|
|
9110
|
+
console.error(`[DIAG] FAILED to activate: ${app.manifest.id}`, err);
|
|
9053
9111
|
warn("Syntro Bootstrap", `Failed to auto-activate built-in app: ${app.manifest.id}`, err);
|
|
9054
9112
|
}
|
|
9055
9113
|
}
|
|
9056
9114
|
}
|
|
9115
|
+
console.log(`[DIAG] Activation complete. Total widgets: [${runtime3.widgets.list().join(", ")}]`);
|
|
9057
9116
|
if (experiments == null ? void 0 : experiments.refreshFeatures) {
|
|
9058
9117
|
try {
|
|
9059
9118
|
await experiments.refreshFeatures();
|
|
@@ -9263,4 +9322,4 @@ export {
|
|
|
9263
9322
|
encodeToken,
|
|
9264
9323
|
Syntro
|
|
9265
9324
|
};
|
|
9266
|
-
//# sourceMappingURL=chunk-
|
|
9325
|
+
//# sourceMappingURL=chunk-ZHIFNJPT.js.map
|