@micro-lc/preview 0.4.2 → 0.5.0-rc1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +3 -4
- package/dist/index.d.ts +24 -3
- package/dist/index.js +13 -10
- package/dist/service-worker.d.ts +28 -0
- package/dist/service-worker.js +1 -0
- package/package.json +7 -6
- package/website/development/index.html +1 -1
- package/website/development/{assets/index-dafdc2d8.js → index.js} +445 -218
- package/website/development/manifest.json +6 -1
- package/website/development/service-worker.js +99 -0
- package/website/index.html +1 -1
- package/website/index.js +13 -0
- package/website/manifest.json +6 -1
- package/website/service-worker.js +1 -0
- package/website/assets/index-de9f10b5.js +0 -13
package/CHANGELOG.md
CHANGED
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
|
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.
|
11
|
-
'ctrl-space': DebugMessage.
|
10
|
+
'click-element': DebugMessage.Skip,
|
11
|
+
'ctrl-space': DebugMessage.Skip,
|
12
12
|
'focus-element': DebugMessage.Default,
|
13
|
-
mousedown: DebugMessage.
|
13
|
+
mousedown: DebugMessage.Skip,
|
14
14
|
mousemove: DebugMessage.Skip,
|
15
15
|
'new-configuration': DebugMessage.Default,
|
16
|
-
notification: DebugMessage.
|
17
|
-
options: DebugMessage.
|
18
|
-
'request-resource': DebugMessage.
|
19
|
-
'
|
20
|
-
|
21
|
-
|
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) {
|
@@ -84,6 +86,7 @@ class PostChannel {
|
|
84
86
|
const hasTop = this.__window.top !== this.__window;
|
85
87
|
console.groupCollapsed(`%c Msg from ${this.__window.origin} ${hasTop ? '(inner)' : '(top)'} `, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join('; '));
|
86
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.document);
|
87
90
|
console.log(message.content);
|
88
91
|
console.groupEnd();
|
89
92
|
}
|
@@ -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.
|
3
|
+
"version": "0.5.0-rc1",
|
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.
|
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.
|
31
|
-
"@types/node": "^
|
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.
|
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
|
}
|