@myop/sdk 0.4.0-beta.3 → 0.4.0-beta.5
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/bundled-declarations.d.ts +43 -2
- package/dist/cjs/_IframeSDK.47f37ec9.min.js +1 -0
- package/dist/cjs/{_IframeSDK.c2e3efb9.js → _IframeSDK.ac4c28cf.js} +87 -7
- package/dist/cjs/_IframeSDK.ac4c28cf.js.map +7 -0
- package/dist/cjs/{_WebComponentSDK.3728ca8b.js → _WebComponentSDK.4085389a.js} +87 -7
- package/dist/cjs/_WebComponentSDK.4085389a.js.map +7 -0
- package/dist/cjs/_WebComponentSDK.4ca43f0a.min.js +1 -0
- package/dist/cjs/_hostSDK.0443afcd.min.js +1 -0
- package/dist/cjs/{_hostSDK.94744d97.js → _hostSDK.46b85afc.js} +87 -7
- package/dist/cjs/_hostSDK.46b85afc.js.map +7 -0
- package/dist/cjs/myop_sdk.js +11 -11
- package/dist/cjs/myop_sdk.js.map +1 -1
- package/dist/cjs/myop_sdk.min.js +1 -1
- package/dist/cjs-bundled/myop_sdk.bundled.js +88 -8
- package/dist/cjs-bundled/myop_sdk.bundled.js.map +2 -2
- package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
- package/dist/module/Iframe/index.js +88 -8
- package/dist/module/Iframe/index.js.map +2 -2
- package/dist/module/SDK.js +88 -8
- package/dist/module/SDK.js.map +2 -2
- package/dist/module/embeddedSDK.js +1 -1
- package/dist/module/host/components/myopExtractedWebComponent.d.ts +24 -1
- package/dist/module/host/embeddedSDK.js +1 -1
- package/dist/module/host/index.js +88 -8
- package/dist/module/host/index.js.map +2 -2
- package/dist/module/host/loaders/HTMLComponentLoader.d.ts +19 -1
- package/dist/module/webcomponent/index.js +88 -8
- package/dist/module/webcomponent/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/cjs/_IframeSDK.3faa31eb.min.js +0 -1
- package/dist/cjs/_IframeSDK.c2e3efb9.js.map +0 -7
- package/dist/cjs/_WebComponentSDK.3728ca8b.js.map +0 -7
- package/dist/cjs/_WebComponentSDK.e517f1a4.min.js +0 -1
- package/dist/cjs/_hostSDK.48b3ff7a.min.js +0 -1
- package/dist/cjs/_hostSDK.94744d97.js.map +0 -7
|
@@ -1190,6 +1190,67 @@ var MyopExtractedWebComponent = class extends BaseMyopComponent {
|
|
|
1190
1190
|
this._ctaQueue.push({ action: detail.action, payload: detail.payload });
|
|
1191
1191
|
}
|
|
1192
1192
|
});
|
|
1193
|
+
__publicField(this, "_autoSizeOptions");
|
|
1194
|
+
/**
|
|
1195
|
+
* Data-out for size — the extracted counterpart of the iframe implementation.
|
|
1196
|
+
*
|
|
1197
|
+
* THIS EXISTED ONLY ON MyopIframeComponent, and that was invisible for as long as
|
|
1198
|
+
* minification was sending every v2 component down the iframe path. Restoring v2
|
|
1199
|
+
* detection moves them to this class, and `@myop/react` drives both through one
|
|
1200
|
+
* wrapper: in content mode it hides its loader from the FIRST onSizeChange, so a
|
|
1201
|
+
* component whose class has no observeAutoSize leaves a React host on a loader
|
|
1202
|
+
* forever. Pic-Time's sizeMeta is width:100% with no height, which is exactly content
|
|
1203
|
+
* mode. Caught by v2-data-contract D8 (API parity).
|
|
1204
|
+
*
|
|
1205
|
+
* It REPORTS rather than imposes. An iframe has no intrinsic size and must be
|
|
1206
|
+
* measured inside and then set from outside; a custom element sizes itself from its
|
|
1207
|
+
* own content, so the honest thing is to measure it and tell the host, and let the
|
|
1208
|
+
* host decide. React then uses width:100% and the measured height.
|
|
1209
|
+
*
|
|
1210
|
+
* The one thing it does impose is `display: block` when the element computes to
|
|
1211
|
+
* `inline`, which is the default for a custom element and measures as zero height no
|
|
1212
|
+
* matter what it contains. The iframe path forces width:100% for the same reason —
|
|
1213
|
+
* without it the first measurement is 0 and the host sizes the component to nothing.
|
|
1214
|
+
*/
|
|
1215
|
+
__publicField(this, "observeAutoSize", (options) => {
|
|
1216
|
+
this._autoSizeOptions = options;
|
|
1217
|
+
const el = this.customElement;
|
|
1218
|
+
try {
|
|
1219
|
+
if (getComputedStyle(el).display === "inline") el.style.display = "block";
|
|
1220
|
+
} catch (e) {
|
|
1221
|
+
}
|
|
1222
|
+
const parse = (v) => {
|
|
1223
|
+
if (v === void 0) return void 0;
|
|
1224
|
+
if (typeof v === "number") return v;
|
|
1225
|
+
const n = parseFloat(v);
|
|
1226
|
+
return isNaN(n) ? void 0 : n;
|
|
1227
|
+
};
|
|
1228
|
+
const clamp = (v, min, max) => min !== void 0 && v < min ? min : max !== void 0 && v > max ? max : v;
|
|
1229
|
+
const report = () => {
|
|
1230
|
+
var _a;
|
|
1231
|
+
const opts = this._autoSizeOptions;
|
|
1232
|
+
const rect = el.getBoundingClientRect();
|
|
1233
|
+
const autoHeight = (opts == null ? void 0 : opts.explicitHeight) === void 0;
|
|
1234
|
+
(_a = opts == null ? void 0 : opts.onSizeChange) == null ? void 0 : _a.call(opts, {
|
|
1235
|
+
width: rect.width,
|
|
1236
|
+
height: autoHeight ? clamp(rect.height, parse(opts == null ? void 0 : opts.minHeight), parse(opts == null ? void 0 : opts.maxHeight)) : rect.height,
|
|
1237
|
+
autoSizingWidth: false,
|
|
1238
|
+
// a web component fills its container's width
|
|
1239
|
+
autoSizingHeight: autoHeight
|
|
1240
|
+
});
|
|
1241
|
+
};
|
|
1242
|
+
let ro;
|
|
1243
|
+
try {
|
|
1244
|
+
ro = new ResizeObserver(() => report());
|
|
1245
|
+
ro.observe(el);
|
|
1246
|
+
} catch (e) {
|
|
1247
|
+
}
|
|
1248
|
+
report();
|
|
1249
|
+
return () => {
|
|
1250
|
+
ro == null ? void 0 : ro.disconnect();
|
|
1251
|
+
this._autoSizeOptions = void 0;
|
|
1252
|
+
};
|
|
1253
|
+
});
|
|
1193
1254
|
__publicField(this, "cleanupInspect", () => {
|
|
1194
1255
|
});
|
|
1195
1256
|
/**
|
|
@@ -2186,7 +2247,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
|
|
|
2186
2247
|
};
|
|
2187
2248
|
|
|
2188
2249
|
// version:myop-sdk-version
|
|
2189
|
-
var myop_sdk_version_default = "0.4.0-beta.
|
|
2250
|
+
var myop_sdk_version_default = "0.4.0-beta.5";
|
|
2190
2251
|
|
|
2191
2252
|
// src/helpers/deliveryStore.ts
|
|
2192
2253
|
var DB_NAME = "myop-delivery";
|
|
@@ -3025,14 +3086,14 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
|
|
|
3025
3086
|
if (!isolate) {
|
|
3026
3087
|
doc.writeln("".concat(sdkScript).concat(initScript));
|
|
3027
3088
|
}
|
|
3028
|
-
if (!isolate && (options == null ? void 0 : options.data) !== void 0) {
|
|
3089
|
+
if (!isolate && (options == null ? void 0 : options.data) !== void 0 && (options == null ? void 0 : options.data) !== null) {
|
|
3029
3090
|
const ctaQueueScript = "<script>\n window.__myop_cta_queue = [];\n window.myop_cta_handler = function(action, payload) {\n window.__myop_cta_queue.push({action: action, payload: payload});\n };\n <\/script>";
|
|
3030
3091
|
const escapedData = JSON.stringify(options.data).replace(/<\/script/gi, "\\u003c/script");
|
|
3031
3092
|
const dataScript = '<script id="__myop_init_data_script">\n (function() {\n var data = '.concat(escapedData, ";\n var scriptEl = document.getElementById('__myop_init_data_script');\n\n var callInitInterface = function(fn) {\n var startTime = performance.now();\n // Mark as pre-injected data call for extension tracking\n window.__myop_init_preinjected = true;\n try {\n fn(data);\n } finally {\n window.__myop_init_preinjected = false;\n }\n var duration = performance.now() - startTime;\n\n // Notify extension via postMessage (init* = pre-injected)\n try {\n window.parent.postMessage({\n type: 'MYOP_PREINJECTED_INIT',\n payload: {\n data: data,\n duration: duration,\n timestamp: Date.now()\n }\n }, '*');\n } catch (e) {}\n\n // Cleanup: remove script tag and stored data\n if (scriptEl && scriptEl.parentNode) {\n scriptEl.parentNode.removeChild(scriptEl);\n }\n delete window.__myop_init_data;\n };\n\n if (typeof window.myop_init_interface === 'function') {\n // Function already exists - call immediately\n callInitInterface(window.myop_init_interface);\n } else {\n // Function not yet defined - store data and watch for definition\n window.__myop_init_data = data;\n\n var _original;\n Object.defineProperty(window, 'myop_init_interface', {\n configurable: true,\n enumerable: true,\n set: function(fn) {\n _original = fn;\n if (window.__myop_init_data !== undefined) {\n var storedData = window.__myop_init_data;\n delete window.__myop_init_data;\n callInitInterface(fn);\n }\n },\n get: function() {\n return _original;\n }\n });\n }\n })();\n <\/script>");
|
|
3032
3093
|
doc.writeln(ctaQueueScript + dataScript);
|
|
3033
3094
|
}
|
|
3034
3095
|
if (isolate) {
|
|
3035
|
-
const escapedData = (options == null ? void 0 : options.data) !== void 0 ? JSON.stringify(options.data).replace(/<\/script/gi, "\\u003c/script") : "undefined";
|
|
3096
|
+
const escapedData = (options == null ? void 0 : options.data) !== void 0 && (options == null ? void 0 : options.data) !== null ? JSON.stringify(options.data).replace(/<\/script/gi, "\\u003c/script") : "undefined";
|
|
3036
3097
|
doc.writeln(this.buildIsolationBridge(escapedData));
|
|
3037
3098
|
}
|
|
3038
3099
|
doc.close();
|
|
@@ -3087,10 +3148,29 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
|
|
|
3087
3148
|
});
|
|
3088
3149
|
}
|
|
3089
3150
|
/**
|
|
3090
|
-
* Detect if HTML is a Myop Web Component
|
|
3151
|
+
* Detect if HTML is a Myop Web Component.
|
|
3152
|
+
*
|
|
3153
|
+
* THE MARKER COMMENT ALONE IS NOT A SAFE SIGNAL, BECAUSE MINIFIERS DELETE COMMENTS.
|
|
3154
|
+
*
|
|
3155
|
+
* This used to be `startsWith(MYOP_WEB_COMPONENT_MARKER)` and nothing else. The
|
|
3156
|
+
* delivery lane minifies with `removeComments: true` (myop-server derive.ts MIN_CFG),
|
|
3157
|
+
* so the stored `min` artifact of every v2 web component loses its leading
|
|
3158
|
+
* `<!-- myop-web-component -->`. Detection then returned false, the component fell
|
|
3159
|
+
* back to plain iframe rendering, and the whole authored document was shown --
|
|
3160
|
+
* including the v2 authoring wrapper, so Pic-Time's production dashboard displayed the
|
|
3161
|
+
* preview chrome ("Web Component v2", a tag-name badge reading `loading...`, SIZE /
|
|
3162
|
+
* OVERFLOW / BG controls) instead of their component. Reported 2026-10-18; the served
|
|
3163
|
+
* HTML measured 328,071 bytes against 951,130 at origin, with zero `<!--` left in it.
|
|
3164
|
+
*
|
|
3165
|
+
* The script id is the signal that survives, and it is the one `extractWebComponentScript`
|
|
3166
|
+
* already depends on: if that element is present, extraction works, so detection
|
|
3167
|
+
* should agree. Checked with a regex rather than DOMParser -- this runs for every
|
|
3168
|
+
* HTML component, and parsing a 300 KB document to answer a yes/no question is not
|
|
3169
|
+
* worth it.
|
|
3091
3170
|
*/
|
|
3092
3171
|
isMyopWebComponent(html) {
|
|
3093
|
-
|
|
3172
|
+
if (html.trimStart().startsWith(MYOP_WEB_COMPONENT_MARKER)) return true;
|
|
3173
|
+
return new RegExp("<script[^>]*\\sid=[\"']?".concat(MYOP_WEB_COMPONENT_SCRIPT_ID, "[\"'\\s>]"), "i").test(html);
|
|
3094
3174
|
}
|
|
3095
3175
|
/**
|
|
3096
3176
|
* Resolve how this component should render, applying the host render policy.
|
|
@@ -3185,7 +3265,6 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
|
|
|
3185
3265
|
if (!container.querySelector('[id^="myop-comp-"]')) {
|
|
3186
3266
|
container.innerHTML = "";
|
|
3187
3267
|
}
|
|
3188
|
-
this.appendChild(container, element, options);
|
|
3189
3268
|
const component = new MyopExtractedWebComponent(
|
|
3190
3269
|
componentDefinition,
|
|
3191
3270
|
skin,
|
|
@@ -3194,7 +3273,8 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
|
|
|
3194
3273
|
tagName,
|
|
3195
3274
|
options
|
|
3196
3275
|
);
|
|
3197
|
-
|
|
3276
|
+
this.appendChild(container, element, options);
|
|
3277
|
+
if ((options == null ? void 0 : options.data) !== void 0 && (options == null ? void 0 : options.data) !== null) {
|
|
3198
3278
|
component.initWithData(options.data);
|
|
3199
3279
|
}
|
|
3200
3280
|
console.log("[MyopWebComponent] Loaded <".concat(tagName, "> into container"));
|