@micro-lc/preview 0.4.2 → 0.5.0-rc2

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,9 @@
1
1
  ## Unreleased
2
2
 
3
- ## [0.4.2] - 2023-05-09
4
-
5
- ### Added
3
+ ### Versioning
6
4
 
7
- - added support for `zone.js`
5
+ - `rxjs` bumped to version `v7.8.1`
6
+ - development dependencies bumped
8
7
 
9
8
  ## [0.4.1] - 2023-04-07
10
9
 
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { Component, PluginConfiguration } from '@micro-lc/interfaces/schema
3
3
  interface TagInfo {
4
4
  definitions?: Record<string, unknown>;
5
5
  description?: string;
6
+ docLink?: string;
6
7
  label?: string;
7
8
  properties?: Manifest['properties'];
8
9
  type?: Manifest['type'];
@@ -59,6 +60,24 @@ interface UpdatedMessage {
59
60
  }
60
61
  type RegisteredConfigMessages = NewConfigurationMessage | UpdateConfigurationMessage;
61
62
  type ReducedMouseEvent = Pick<MouseEvent, 'bubbles' | 'cancelable' | 'clientX' | 'clientY'>;
63
+ interface ServiceWorkerConfig {
64
+ dictionary: Record<`${string}/`, {
65
+ headers: Record<string, string>;
66
+ query: Record<string, string>;
67
+ to: `${string}/`;
68
+ }>;
69
+ scope?: string;
70
+ }
71
+ interface SourceMapMessage {
72
+ content: ServiceWorkerConfig;
73
+ type: 'set-source-map';
74
+ }
75
+ interface ServiceWorkerMessage {
76
+ content: {
77
+ status: 'ready';
78
+ };
79
+ type: 'service-worker';
80
+ }
62
81
  type RegisteredMessages = {
63
82
  content: ReducedMouseEvent;
64
83
  type: 'mousedown' | 'mousemove';
@@ -73,7 +92,7 @@ type RegisteredMessages = {
73
92
  } | {
74
93
  content: InfoEntry[];
75
94
  type: 'tag-info';
76
- } | RegisteredConfigMessages | UpdatedMessage | RegisteredElementMessages | OptionMessage | RequestResource;
95
+ } | RegisteredConfigMessages | UpdatedMessage | RegisteredElementMessages | OptionMessage | RequestResource | SourceMapMessage | ServiceWorkerMessage;
77
96
  interface NotifyProps extends Record<string, unknown> {
78
97
  data?: Record<string, string>;
79
98
  description: string;
@@ -96,6 +115,7 @@ declare const MIA_PREVIEW_ID = "__mia_preview_id";
96
115
  declare const OVERLAY_Z_INDEX = 1000000;
97
116
  declare const DEFAULT_MODE = "select";
98
117
  declare function isRegisteredMessage(input: unknown): input is RegisteredMessages;
118
+ declare const generateDarkColorHex: () => string;
99
119
  declare class PostChannel {
100
120
  private __instance;
101
121
  private __handler;
@@ -109,6 +129,7 @@ declare class PostChannel {
109
129
  send(to: Window, message: RegisteredMessages, origin?: string): void;
110
130
  recv(window: Window, from?: Window | null): () => void;
111
131
  }
112
- export type { OverlayMode, InfoEntry, ElementContent, StyledElementContent, NewConfigurationMessage, UpdateConfigurationMessage, RegisteredConfigMessages, RegisteredMessages, OptionMessage, NotifyProps, Reset, Update, RequestResource, };
113
- export { MIA_PREVIEW_ID, OVERLAY_Z_INDEX, DEFAULT_MODE, isRegisteredMessage, PostChannel, };
132
+ export type { OverlayMode, TagInfo, InfoEntry, ElementContent, StyledElementContent, NewConfigurationMessage, UpdateConfigurationMessage, RegisteredConfigMessages, RegisteredMessages, OptionMessage, NotifyProps, Reset, Update, RequestResource, SourceMapMessage, ServiceWorkerConfig, };
133
+ export type * from './service-worker';
134
+ export { MIA_PREVIEW_ID, OVERLAY_Z_INDEX, DEFAULT_MODE, generateDarkColorHex, isRegisteredMessage, PostChannel, };
114
135
  export * from './handlebars';
package/dist/index.js CHANGED
@@ -7,18 +7,20 @@ const MIA_PREVIEW_ID = '__mia_preview_id';
7
7
  const OVERLAY_Z_INDEX = 1_000_000;
8
8
  const DEFAULT_MODE = 'select';
9
9
  const keys = {
10
- 'click-element': DebugMessage.Default,
11
- 'ctrl-space': DebugMessage.Default,
10
+ 'click-element': DebugMessage.Skip,
11
+ 'ctrl-space': DebugMessage.Skip,
12
12
  'focus-element': DebugMessage.Default,
13
- mousedown: DebugMessage.Default,
13
+ mousedown: DebugMessage.Skip,
14
14
  mousemove: DebugMessage.Skip,
15
15
  'new-configuration': DebugMessage.Default,
16
- notification: DebugMessage.Default,
17
- options: DebugMessage.Default,
18
- 'request-resource': DebugMessage.Default,
19
- 'tag-info': DebugMessage.Default,
20
- update: DebugMessage.Default,
21
- updated: DebugMessage.Default,
16
+ notification: DebugMessage.Skip,
17
+ options: DebugMessage.Skip,
18
+ 'request-resource': DebugMessage.Skip,
19
+ 'service-worker': DebugMessage.Skip,
20
+ 'set-source-map': DebugMessage.Default,
21
+ 'tag-info': DebugMessage.Skip,
22
+ update: DebugMessage.Skip,
23
+ updated: DebugMessage.Skip,
22
24
  };
23
25
  const isValidKey = (type) => Object.keys(keys).includes(type);
24
26
  function isRegisteredMessage(input) {
@@ -77,16 +79,17 @@ class PostChannel {
77
79
  if (import.meta.env.MODE !== 'production' || this.__window.__BACKOFFICE_CONFIGURATOR_LOG_LEVEL__ === 'debug') {
78
80
  console.assert(to !== this.__window);
79
81
  }
80
- if ((import.meta.env.MODE !== 'production' || this.__window.__BACKOFFICE_CONFIGURATOR_LOG_LEVEL__ === 'debug') && keys[message.type] !== DebugMessage.Skip) {
81
- const color = this.__randomColor;
82
- const background = `${color}22`;
83
- const style = { background, color };
84
- const hasTop = this.__window.top !== this.__window;
85
- console.groupCollapsed(`%c Msg from ${this.__window.origin} ${hasTop ? '(inner)' : '(top)'} `, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join('; '));
86
- console.info(`window '${this.__window.origin}' is sending a message of type %c ${message.type} `, 'background: lightgreen; color: darkgreen');
87
- console.log(message.content);
88
- console.groupEnd();
89
- }
82
+ // if ((import.meta.env.MODE !== 'production' || this.__window.__BACKOFFICE_CONFIGURATOR_LOG_LEVEL__ === 'debug') && keys[message.type] !== DebugMessage.Skip) {
83
+ const color = this.__randomColor;
84
+ const background = `${color}22`;
85
+ const style = { background, color };
86
+ const hasTop = this.__window.top !== this.__window;
87
+ console.groupCollapsed(`%c Msg from ${this.__window.origin} ${hasTop ? '(inner)' : '(top)'} `, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join('; '));
88
+ console.info(`window '${this.__window.origin}' is sending a message of type %c ${message.type} `, 'background: lightgreen; color: darkgreen');
89
+ console.log('to', to);
90
+ console.log(message.content);
91
+ console.groupEnd();
92
+ // }
90
93
  to.postMessage(sign(this.__instance, message), origin);
91
94
  }
92
95
  constructor(handler) {
@@ -118,5 +121,5 @@ class PostChannel {
118
121
  return () => window.removeEventListener('message', listener);
119
122
  }
120
123
  }
121
- export { MIA_PREVIEW_ID, OVERLAY_Z_INDEX, DEFAULT_MODE, isRegisteredMessage, PostChannel, };
124
+ export { MIA_PREVIEW_ID, OVERLAY_Z_INDEX, DEFAULT_MODE, generateDarkColorHex, isRegisteredMessage, PostChannel, };
122
125
  export * from './handlebars';
@@ -0,0 +1,28 @@
1
+ interface UrlMatchPair {
2
+ headers: Record<string, string>;
3
+ originalFrom: `${string}/`;
4
+ query: Record<string, string>;
5
+ to: `${string}/`;
6
+ }
7
+ interface SourceMapItems {
8
+ dictionary: Record<`${string}/`, UrlMatchPair>;
9
+ scope?: string;
10
+ }
11
+ type WorkerMessage = {
12
+ content: SourceMapItems;
13
+ type: 'set-source-map';
14
+ } | {
15
+ content: {
16
+ clientId: string;
17
+ };
18
+ type: 'source-map-ack';
19
+ } | {
20
+ content: {
21
+ status: 'ready';
22
+ };
23
+ type: 'service-worker';
24
+ } | {
25
+ content: Record<string, never>;
26
+ type: 'unload-client';
27
+ };
28
+ export type { SourceMapItems, UrlMatchPair, WorkerMessage, };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micro-lc/preview",
3
- "version": "0.4.2",
3
+ "version": "0.5.0-rc2",
4
4
  "module": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -22,18 +22,19 @@
22
22
  "dependencies": {
23
23
  "@micro-lc/composer": "^2.0.3",
24
24
  "es-module-shims": "^1.7.2",
25
- "rxjs": "^7.8.0"
25
+ "rxjs": "^7.8.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@micro-lc/back-kit-engine": "^0.20.11",
29
29
  "@micro-lc/interfaces": "^1.0.2",
30
- "@playwright/test": "^1.32.3",
31
- "@types/node": "^18.15.11",
30
+ "@playwright/test": "^1.34.2",
31
+ "@types/node": "^20.2.1",
32
32
  "npm-run-all": "^4.1.5",
33
33
  "typescript": "^5.0.4",
34
- "vite": "^4.2.2"
34
+ "vite": "^4.3.8"
35
35
  },
36
36
  "engines": {
37
37
  "node": ">=v16.20.0"
38
- }
38
+ },
39
+ "stableVersion": "0.4.1"
39
40
  }
@@ -17,7 +17,7 @@
17
17
  </style>
18
18
  <script src="https://unpkg.com/zone.js"></script>
19
19
 
20
- <script type="module" crossorigin src="./assets/index-dafdc2d8.js"></script>
20
+ <script type="module" crossorigin src="./index.js"></script>
21
21
  </head>
22
22
  <body></body>
23
23
  </html>