@lvce-editor/iframe-worker 6.4.0 → 6.5.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.
@@ -96,6 +96,18 @@ const object = value => {
96
96
  throw new AssertionError('expected value to be of type object');
97
97
  }
98
98
  };
99
+ const number = value => {
100
+ const type = getType(value);
101
+ if (type !== Number$1) {
102
+ throw new AssertionError('expected value to be of type number');
103
+ }
104
+ };
105
+ const string = value => {
106
+ const type = getType(value);
107
+ if (type !== String) {
108
+ throw new AssertionError('expected value to be of type string');
109
+ }
110
+ };
99
111
 
100
112
  const isMessagePort = value => {
101
113
  return value && value instanceof MessagePort;
@@ -1061,6 +1073,9 @@ const createMockRpc = ({
1061
1073
  return mockRpc;
1062
1074
  };
1063
1075
 
1076
+ const Div = 4;
1077
+ const Iframe = 68;
1078
+
1064
1079
  const ExtensionHostWorker = 44;
1065
1080
  const RendererWorker$1 = 1;
1066
1081
 
@@ -2132,20 +2147,24 @@ const {
2132
2147
  set,
2133
2148
  wrapCommand} = create();
2134
2149
 
2135
- // TODO parentUid might ot be needed
2136
- const create4 = (id, uri, x, y, width, height, args, parentUid, platform = 0, assetDir = '') => {
2150
+ const create4 = (id, uri, x, y, width, height, platform, assetDir) => {
2151
+ number(platform);
2152
+ string(assetDir);
2137
2153
  const state = {
2154
+ assetDir,
2138
2155
  credentialless: true,
2139
2156
  csp: '',
2140
2157
  height,
2141
2158
  id,
2142
2159
  iframeSrc: '',
2143
2160
  origin: '',
2161
+ platform,
2144
2162
  portId: 0,
2145
2163
  previewServerId: 1,
2146
2164
  sandbox: [],
2147
2165
  srcDoc: '',
2148
2166
  uri,
2167
+ webViewScheme: '',
2149
2168
  width,
2150
2169
  x: x - 1,
2151
2170
  y
@@ -2154,7 +2173,7 @@ const create4 = (id, uri, x, y, width, height, args, parentUid, platform = 0, as
2154
2173
  };
2155
2174
 
2156
2175
  const isEqual = (oldState, newState) => {
2157
- return oldState.iframeSrc === newState.iframeSrc;
2176
+ return oldState === newState;
2158
2177
  };
2159
2178
 
2160
2179
  const RenderItems = 1;
@@ -2211,23 +2230,30 @@ const initialize = async platform => {
2211
2230
  };
2212
2231
 
2213
2232
  const loadContent = async (state, savedState) => {
2233
+ // @ts-ignore
2234
+ const {
2235
+ assetDir,
2236
+ id,
2237
+ platform,
2238
+ uri,
2239
+ webViewScheme
2240
+ } = state;
2241
+ await invoke$4('WebView.create3', {
2242
+ assetDir,
2243
+ id,
2244
+ platform,
2245
+ uri,
2246
+ useNewWebViewHandler: true,
2247
+ webViewScheme
2248
+ });
2249
+
2250
+ // TODO get iframe src
2214
2251
  // TODO load webview props and register protocol
2215
2252
  return {
2216
2253
  ...state
2217
2254
  };
2218
2255
  };
2219
2256
 
2220
- const Div = 4;
2221
- const Text = 12;
2222
-
2223
- const text = data => {
2224
- return {
2225
- childCount: 0,
2226
- text: data,
2227
- type: Text
2228
- };
2229
- };
2230
-
2231
2257
  const renderItems = (oldState, newState) => {
2232
2258
  const {
2233
2259
  id
@@ -2235,7 +2261,12 @@ const renderItems = (oldState, newState) => {
2235
2261
  const dom = [{
2236
2262
  childCount: 1,
2237
2263
  type: Div
2238
- }, text('hllo world')];
2264
+ }, {
2265
+ childCount: 0,
2266
+ src: 'https://example.com',
2267
+ // @ts-ignore
2268
+ type: Iframe
2269
+ }];
2239
2270
  return [SetDom2, id, dom];
2240
2271
  };
2241
2272
 
@@ -2270,6 +2301,10 @@ const render2 = (uid, diffResult) => {
2270
2301
  return commands;
2271
2302
  };
2272
2303
 
2304
+ const renderEventListeners = () => {
2305
+ return [];
2306
+ };
2307
+
2273
2308
  const saveState = async () => {
2274
2309
  const all = getAll$1();
2275
2310
  const serialized = [];
@@ -2309,17 +2344,22 @@ const commandMap = {
2309
2344
  'WebView.loadContent': wrapCommand(loadContent),
2310
2345
  'WebView.registerInterceptor': registerInterceptor,
2311
2346
  'WebView.render2': render2,
2347
+ 'WebView.renderEventListeners': renderEventListeners,
2312
2348
  'WebView.saveState': saveState,
2313
2349
  'WebView.unregisterInterceptor': unregisterInterceptor
2314
2350
  };
2315
2351
 
2316
- const listen = async () => {
2352
+ const initializeRendererWorker = async () => {
2317
2353
  const rpc = await WebWorkerRpcClient.create({
2318
2354
  commandMap: commandMap
2319
2355
  });
2320
2356
  set$2(rpc);
2321
2357
  };
2322
2358
 
2359
+ const listen = async () => {
2360
+ await initializeRendererWorker();
2361
+ };
2362
+
2323
2363
  const main = async () => {
2324
2364
  await listen();
2325
2365
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/iframe-worker",
3
- "version": "6.4.0",
3
+ "version": "6.5.0",
4
4
  "description": "Web Worker to manage creation and lifecycle of iframes in Lvce Editor",
5
5
  "keywords": [
6
6
  "iframe"