@origostudio/origo-design 0.0.30 → 0.0.32
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/CHANGELOG.md +4 -4
- package/dist/packages/angular-renderer/CHANGELOG.md +21 -0
- package/dist/packages/angular-renderer/package.json +3 -3
- package/dist/packages/angular-renderer/src/devtools/devtools-bridge.d.ts +3 -1
- package/dist/packages/angular-renderer/src/devtools/devtools-bridge.js +64 -4
- package/dist/packages/angular-renderer/src/devtools/devtools-bridge.js.map +1 -1
- package/dist/packages/angular-renderer/src/index.d.ts +1 -0
- package/dist/packages/angular-renderer/src/index.js +1 -0
- package/dist/packages/angular-renderer/src/index.js.map +1 -1
- package/dist/packages/cli/CHANGELOG.md +8 -0
- package/dist/packages/cli/package.json +2 -2
- package/dist/packages/cli/package.json.bak +2 -2
- package/dist/packages/core/CHANGELOG.md +8 -0
- package/dist/packages/core/package.json +1 -1
- package/dist/packages/core/package.json.bak +1 -1
- package/dist/packages/design-tokens/CHANGELOG.md +8 -0
- package/dist/packages/design-tokens/package.json +1 -1
- package/dist/packages/devtools/browser/devtools.html +19 -0
- package/dist/packages/devtools/browser/devtools.js +10 -0
- package/dist/packages/devtools/browser/main.js +4 -0
- package/dist/packages/devtools/browser/manifest.json +24 -0
- package/dist/packages/devtools/browser/panel.html +13 -0
- package/dist/packages/devtools/prerendered-routes.json +3 -0
- package/dist/packages/playground/browser/{chunk-3_MCIwP9.js → chunk-0atszSIl.js} +1 -1
- package/dist/packages/playground/browser/{chunk-Db-66oBG.js → chunk-BU8WdTDW.js} +1 -1
- package/dist/packages/playground/browser/{chunk-DTWyZJQn.js → chunk-Bl2XUkt9.js} +1 -1
- package/dist/packages/playground/browser/{chunk-BfRxMFzC.js → chunk-BnQm5_3H.js} +1 -1
- package/dist/packages/playground/browser/{chunk-BNWpW9dI.js → chunk-BoABL5Us.js} +1 -1
- package/dist/packages/playground/browser/{chunk-DaAkzkdj.js → chunk-CCQ1RKCp.js} +1 -1
- package/dist/packages/playground/browser/{chunk-ukC1CGrX.js → chunk-CCwqbbdB.js} +1 -1
- package/dist/packages/playground/browser/{chunk-CxuQUL9T.js → chunk-Cs5LSVZ4.js} +1 -1
- package/dist/packages/playground/browser/{chunk-Cw0imz7o.js → chunk-D-D574YC.js} +1 -1
- package/dist/packages/playground/browser/{chunk-CTOW2Wjn.js → chunk-DGDHcpBL.js} +1 -1
- package/dist/packages/playground/browser/{chunk-Csk-gzld.js → chunk-DblWUBCc.js} +1 -1
- package/dist/packages/playground/browser/{chunk-GJ-FyJ-_.js → chunk-DmH1uLzp.js} +1 -1
- package/dist/packages/playground/browser/{chunk-ChHaxBw8.js → chunk-DoeRt62n.js} +1 -1
- package/dist/packages/playground/browser/{chunk-CbkfOqNs.js → chunk-fvcTt7Iz.js} +1 -1
- package/dist/packages/playground/browser/{chunk-ZMJY_Wrl.js → chunk-iUjqeDU_.js} +1 -1
- package/dist/packages/playground/browser/index.html +1 -1
- package/dist/packages/playground/browser/main-YU4BRK3G.js +711 -0
- package/graph.json +1052 -0
- package/package.json +2 -1
- package/packages/angular-renderer/CHANGELOG.md +21 -0
- package/packages/angular-renderer/package.json +3 -3
- package/packages/angular-renderer/src/devtools/devtools-bridge.ts +67 -5
- package/packages/angular-renderer/src/index.ts +1 -0
- package/packages/angular-renderer/src/test-setup.ts +9 -0
- package/packages/cli/CHANGELOG.md +8 -0
- package/packages/cli/package.json +2 -2
- package/packages/core/CHANGELOG.md +8 -0
- package/packages/core/package.json +1 -1
- package/packages/design-tokens/CHANGELOG.md +8 -0
- package/packages/design-tokens/package.json +1 -1
- package/packages/devtools/CHANGELOG.md +22 -0
- package/packages/devtools/devtools.html +19 -0
- package/packages/devtools/devtools.js +10 -0
- package/packages/devtools/manifest.json +24 -0
- package/packages/devtools/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/deps___vitest_vm__/_metadata.json +8 -0
- package/packages/devtools/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/deps___vitest_vm__/package.json +3 -0
- package/packages/devtools/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/packages/devtools/package.json +14 -0
- package/packages/devtools/panel.html +16 -0
- package/packages/devtools/src/background/background.ts +57 -0
- package/packages/devtools/src/content-script/content-script.ts +43 -0
- package/packages/devtools/src/content-script/injected.ts +124 -0
- package/packages/devtools/src/devtools-panel/app.component.ts +302 -0
- package/packages/devtools/src/devtools-panel/component-tree/component-tree.component.ts +108 -0
- package/packages/devtools/src/devtools-panel/main.ts +7 -0
- package/packages/devtools/src/devtools-panel/metadata-detail/metadata-detail.component.ts +160 -0
- package/packages/devtools/src/test-setup.ts +49 -0
- package/packages/devtools/src/types/messages.ts +99 -0
- package/packages/devtools/vitest.config.ts +14 -0
- package/packages/playground/CHANGELOG.md +20 -0
- package/packages/playground/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/deps___vitest_vm__/_metadata.json +3 -3
- package/packages/playground/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/packages/playground/package.json +5 -2
- package/packages/playground/src/main.ts +83 -0
- package/packages/playground/src/preview/preview.service.ts +18 -0
- package/dist/packages/playground/browser/main-V25Z5OWF.js +0 -711
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@origostudio/origo-design",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"@playwright/test": "^1.36.0",
|
|
69
69
|
"@schematics/angular": "22.0.9",
|
|
70
70
|
"@swc/helpers": "~0.5.18",
|
|
71
|
+
"@types/chrome": "^0.2.9",
|
|
71
72
|
"@types/jest": "30.0.0",
|
|
72
73
|
"@types/json-source-map": "^0.6.0",
|
|
73
74
|
"@types/node": "^22.12.0",
|
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## 0.0.32 (2026-09-19)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- add devtools bridge to angular renderer package ([26a2a2d](https://github.com/OrigoStudio/origo-design/commit/26a2a2d))
|
|
6
|
+
- implement strict test isolation guards, structured cloning, and update test setup configurations and registry artifacts ([a5e79e2](https://github.com/OrigoStudio/origo-design/commit/a5e79e2))
|
|
7
|
+
|
|
8
|
+
### ❤️ Thank You
|
|
9
|
+
|
|
10
|
+
- Hardik Patel @hardikpatelse
|
|
11
|
+
|
|
12
|
+
## 0.0.31 (2026-09-16)
|
|
13
|
+
|
|
14
|
+
### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- implement Origo DevTools inspector UI and angular-renderer bridge ([dedd240](https://github.com/OrigoStudio/origo-design/commit/dedd240))
|
|
17
|
+
|
|
18
|
+
### ❤️ Thank You
|
|
19
|
+
|
|
20
|
+
- Hardik Patel @hardikpatelse
|
|
21
|
+
|
|
1
22
|
## 0.0.30 (2026-09-15)
|
|
2
23
|
|
|
3
24
|
### 🚀 Features
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "angular-renderer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@origo/core": "0.0.
|
|
10
|
-
"@origo/design-tokens": "0.0.
|
|
9
|
+
"@origo/core": "0.0.32",
|
|
10
|
+
"@origo/design-tokens": "0.0.32",
|
|
11
11
|
"tslib": "^2.3.0",
|
|
12
12
|
"@axe-core/playwright": "^4.13.0",
|
|
13
13
|
"@playwright/test": "^1.36.0"
|
|
@@ -10,7 +10,9 @@ export interface ResolutionChain {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export interface RenderingPath {
|
|
13
|
-
|
|
13
|
+
name: string;
|
|
14
|
+
badlPath: string;
|
|
15
|
+
children?: RenderingPath[];
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export interface ErrorContext {
|
|
@@ -74,8 +76,31 @@ let _internalState: unknown = {
|
|
|
74
76
|
|
|
75
77
|
let _errorTelemetry: ErrorContext[] = [];
|
|
76
78
|
|
|
79
|
+
function deepCloneState(obj: unknown, seen = new WeakMap()): unknown {
|
|
80
|
+
if (obj === null || typeof obj !== 'object') {
|
|
81
|
+
return obj;
|
|
82
|
+
}
|
|
83
|
+
if (seen.has(obj)) {
|
|
84
|
+
return seen.get(obj);
|
|
85
|
+
}
|
|
86
|
+
const clone: any = Array.isArray(obj) ? [] : {};
|
|
87
|
+
seen.set(obj, clone);
|
|
88
|
+
for (const key in obj) {
|
|
89
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
90
|
+
clone[key] = deepCloneState((obj as Record<string, unknown>)[key], seen);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return clone;
|
|
94
|
+
}
|
|
95
|
+
|
|
77
96
|
export function _injectTestState(state: unknown): void {
|
|
78
|
-
|
|
97
|
+
try {
|
|
98
|
+
_internalState =
|
|
99
|
+
typeof structuredClone === 'function' ? structuredClone(state) : deepCloneState(state);
|
|
100
|
+
} catch (e) {
|
|
101
|
+
// Fallback if structuredClone fails (e.g. contains functions or unsupported types)
|
|
102
|
+
_internalState = deepCloneState(state);
|
|
103
|
+
}
|
|
79
104
|
}
|
|
80
105
|
|
|
81
106
|
export function _resetTestState(): void {
|
|
@@ -95,11 +120,48 @@ export function getDevToolsAPI(): OrigoDevToolsAPI | null {
|
|
|
95
120
|
return {
|
|
96
121
|
getActiveState: () => redactSensitiveData(_internalState),
|
|
97
122
|
getRenderingPath: (path: string) => {
|
|
98
|
-
//
|
|
99
|
-
|
|
123
|
+
// Build a tree from _internalState
|
|
124
|
+
const state: any = _internalState;
|
|
125
|
+
|
|
126
|
+
if (state && state.id === 'dom-identity') {
|
|
127
|
+
// Map the provided JSON to a tree
|
|
128
|
+
const root: RenderingPath = {
|
|
129
|
+
name: state.name || 'Root',
|
|
130
|
+
badlPath: `/${state.domain || 'core'}/${state.id}`,
|
|
131
|
+
children: (state.entities || []).map((ent: any) => ({
|
|
132
|
+
name: ent.name,
|
|
133
|
+
badlPath: `/${state.domain || 'core'}/${state.id}/${ent.id}`,
|
|
134
|
+
children: (ent.fields || []).map((fld: any) => ({
|
|
135
|
+
name: fld.name,
|
|
136
|
+
badlPath: fld.metadata_path || `/${ent.id}/${fld.id}`,
|
|
137
|
+
})),
|
|
138
|
+
})),
|
|
139
|
+
};
|
|
140
|
+
return root;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Default fallback
|
|
144
|
+
return {
|
|
145
|
+
name: 'Root Application',
|
|
146
|
+
badlPath: '/',
|
|
147
|
+
children: [],
|
|
148
|
+
};
|
|
100
149
|
},
|
|
101
150
|
getMetadataSource: (path: string) => {
|
|
102
|
-
|
|
151
|
+
// Find the object in _internalState that matches the path
|
|
152
|
+
const state: any = _internalState;
|
|
153
|
+
if (state && state.id === 'dom-identity') {
|
|
154
|
+
// Return the whole state for root, or specific parts based on path
|
|
155
|
+
if (path === `/${state.domain || 'core'}/${state.id}`) return state as any;
|
|
156
|
+
|
|
157
|
+
for (const ent of state.entities || []) {
|
|
158
|
+
if (path === `/${state.domain || 'core'}/${state.id}/${ent.id}`) return ent;
|
|
159
|
+
for (const fld of ent.fields || []) {
|
|
160
|
+
if (path === (fld.metadata_path || `/${ent.id}/${fld.id}`)) return fld;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return { file: 'mock.json', line: 1 } as any;
|
|
103
165
|
},
|
|
104
166
|
getResolutionChain: (path: string) => {
|
|
105
167
|
return null;
|
|
@@ -6,3 +6,12 @@ import {
|
|
|
6
6
|
} from '@angular/platform-browser-dynamic/testing';
|
|
7
7
|
|
|
8
8
|
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
|
|
9
|
+
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
getTestBed().resetTestingModule();
|
|
12
|
+
jest.clearAllMocks();
|
|
13
|
+
jest.restoreAllMocks();
|
|
14
|
+
if (typeof document !== 'undefined') {
|
|
15
|
+
document.body.innerHTML = '';
|
|
16
|
+
}
|
|
17
|
+
});
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 0.0.32 (2026-09-19)
|
|
2
|
+
|
|
3
|
+
This was a version bump only for cli to align it with other projects, there were no code changes.
|
|
4
|
+
|
|
5
|
+
## 0.0.31 (2026-09-16)
|
|
6
|
+
|
|
7
|
+
This was a version bump only for cli to align it with other projects, there were no code changes.
|
|
8
|
+
|
|
1
9
|
## 0.0.30 (2026-09-15)
|
|
2
10
|
|
|
3
11
|
This was a version bump only for cli to align it with other projects, there were no code changes.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@origostudio/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"origo": "./src/main.js"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@origo/core": "0.0.
|
|
12
|
+
"@origo/core": "0.0.32",
|
|
13
13
|
"commander": "^15.0.0",
|
|
14
14
|
"tslib": "^2.3.0"
|
|
15
15
|
},
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 0.0.32 (2026-09-19)
|
|
2
|
+
|
|
3
|
+
This was a version bump only for core to align it with other projects, there were no code changes.
|
|
4
|
+
|
|
5
|
+
## 0.0.31 (2026-09-16)
|
|
6
|
+
|
|
7
|
+
This was a version bump only for core to align it with other projects, there were no code changes.
|
|
8
|
+
|
|
1
9
|
## 0.0.30 (2026-09-15)
|
|
2
10
|
|
|
3
11
|
This was a version bump only for core to align it with other projects, there were no code changes.
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 0.0.32 (2026-09-19)
|
|
2
|
+
|
|
3
|
+
This was a version bump only for design-tokens to align it with other projects, there were no code changes.
|
|
4
|
+
|
|
5
|
+
## 0.0.31 (2026-09-16)
|
|
6
|
+
|
|
7
|
+
This was a version bump only for design-tokens to align it with other projects, there were no code changes.
|
|
8
|
+
|
|
1
9
|
## 0.0.30 (2026-09-15)
|
|
2
10
|
|
|
3
11
|
This was a version bump only for design-tokens to align it with other projects, there were no code changes.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
## 0.0.32 (2026-09-19)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- add devtools and playground packages with retro-8 versioning artifacts ([ff1aedc](https://github.com/OrigoStudio/origo-design/commit/ff1aedc))
|
|
6
|
+
- implement strict test isolation guards, structured cloning, and update test setup configurations and registry artifacts ([a5e79e2](https://github.com/OrigoStudio/origo-design/commit/a5e79e2))
|
|
7
|
+
|
|
8
|
+
### ❤️ Thank You
|
|
9
|
+
|
|
10
|
+
- Hardik Patel @hardikpatelse
|
|
11
|
+
|
|
12
|
+
## 0.0.31 (2026-09-16)
|
|
13
|
+
|
|
14
|
+
### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add Nx project configuration for devtools package ([cb1f628](https://github.com/OrigoStudio/origo-design/commit/cb1f628))
|
|
17
|
+
- add Origo DevTools browser extension package with inspector UI ([4910624](https://github.com/OrigoStudio/origo-design/commit/4910624))
|
|
18
|
+
- implement Origo DevTools inspector UI and angular-renderer bridge ([dedd240](https://github.com/OrigoStudio/origo-design/commit/dedd240))
|
|
19
|
+
|
|
20
|
+
### ❤️ Thank You
|
|
21
|
+
|
|
22
|
+
- Hardik Patel @hardikpatelse
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>Origo DevTools</title>
|
|
6
|
+
<base href="/" />
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
8
|
+
<meta http-equiv="Content-Security-Policy" content="script-src 'self'; object-src 'self';" />
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<!--
|
|
12
|
+
We cannot run inline scripts in MV3 extension pages.
|
|
13
|
+
The actual devtools panel registration happens here if needed,
|
|
14
|
+
or in main.ts. Actually, devtools.html is the devtools_page in manifest,
|
|
15
|
+
which is invisible. It just creates the panel.
|
|
16
|
+
-->
|
|
17
|
+
<script src="devtools.js"></script>
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_version": 3,
|
|
3
|
+
"name": "Origo DevTools",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"description": "Origo DevTools Inspector UI",
|
|
6
|
+
"devtools_page": "devtools.html",
|
|
7
|
+
"background": {
|
|
8
|
+
"service_worker": "background.js",
|
|
9
|
+
"type": "module"
|
|
10
|
+
},
|
|
11
|
+
"content_scripts": [
|
|
12
|
+
{
|
|
13
|
+
"matches": ["http://localhost/*", "http://127.0.0.1/*"],
|
|
14
|
+
"js": ["content-script.js"]
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"web_accessible_resources": [
|
|
18
|
+
{
|
|
19
|
+
"resources": ["injected.js"],
|
|
20
|
+
"matches": ["http://localhost/*", "http://127.0.0.1/*"]
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"permissions": ["tabs"]
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"4.1.11","results":[[":src/devtools-panel/app.component.spec.ts",{"duration":189.16830899999877,"failed":false}]]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@origo/devtools",
|
|
3
|
+
"version": "0.0.32",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@origo/core": "0.0.30",
|
|
7
|
+
"@origostudio/cli": "0.0.30",
|
|
8
|
+
"@angular/core": "18.1.0",
|
|
9
|
+
"@angular/common": "18.1.0"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@types/chrome": "^0.0.268"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>Origo DevTools</title>
|
|
6
|
+
<base href="/" />
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
8
|
+
<meta
|
|
9
|
+
http-equiv="Content-Security-Policy"
|
|
10
|
+
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline';"
|
|
11
|
+
/>
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<origo-devtools-root></origo-devtools-root>
|
|
15
|
+
</body>
|
|
16
|
+
</html>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const connections: { [tabId: number]: chrome.runtime.Port } = {};
|
|
2
|
+
|
|
3
|
+
chrome.runtime.onConnect.addListener(port => {
|
|
4
|
+
if (port.name !== 'origo-devtools-panel') return;
|
|
5
|
+
|
|
6
|
+
const extensionListener = (message: any) => {
|
|
7
|
+
// The original connection event doesn't include the tab ID of the
|
|
8
|
+
// DevTools page, so we need to send it explicitly.
|
|
9
|
+
if (message.name === 'init') {
|
|
10
|
+
const tabId = message.tabId;
|
|
11
|
+
if (tabId != null) {
|
|
12
|
+
if (connections[tabId]) {
|
|
13
|
+
connections[tabId].disconnect();
|
|
14
|
+
}
|
|
15
|
+
connections[tabId] = port;
|
|
16
|
+
}
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Relay message to content script
|
|
21
|
+
if (message.tabId != null && message.data !== undefined) {
|
|
22
|
+
chrome.tabs.sendMessage(message.tabId, message.data).catch(err => {
|
|
23
|
+
console.warn(`Could not send message to tab ${message.tabId}:`, err);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Listen to messages sent from the DevTools page
|
|
29
|
+
port.onMessage.addListener(extensionListener);
|
|
30
|
+
|
|
31
|
+
port.onDisconnect.addListener(port => {
|
|
32
|
+
port.onMessage.removeListener(extensionListener);
|
|
33
|
+
|
|
34
|
+
const tabs = Object.keys(connections);
|
|
35
|
+
for (let i = 0, len = tabs.length; i < len; i++) {
|
|
36
|
+
if (connections[parseInt(tabs[i])] === port) {
|
|
37
|
+
delete connections[parseInt(tabs[i])];
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Receive message from content script and relay to the devTools page for the current tab
|
|
45
|
+
chrome.runtime.onMessage.addListener((request, sender) => {
|
|
46
|
+
// Messages from content scripts should have sender.tab set
|
|
47
|
+
if (sender.tab && sender.tab.id != null) {
|
|
48
|
+
const tabId = sender.tab.id;
|
|
49
|
+
if (tabId in connections) {
|
|
50
|
+
connections[tabId].postMessage(request);
|
|
51
|
+
} else {
|
|
52
|
+
console.log('Tab not found in connection list.');
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
console.log('sender.tab not defined.');
|
|
56
|
+
}
|
|
57
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Inject the script into the main world
|
|
2
|
+
const root = document.head || document.documentElement;
|
|
3
|
+
if (root) {
|
|
4
|
+
const script = document.createElement('script');
|
|
5
|
+
script.src = chrome.runtime.getURL('injected.js');
|
|
6
|
+
root.appendChild(script);
|
|
7
|
+
script.onload = () => {
|
|
8
|
+
script.remove();
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Relay messages from background to injected script
|
|
13
|
+
chrome.runtime.onMessage.addListener(message => {
|
|
14
|
+
window.postMessage(
|
|
15
|
+
{
|
|
16
|
+
source: 'origo-devtools-content-script',
|
|
17
|
+
payload: message,
|
|
18
|
+
},
|
|
19
|
+
window.location.origin
|
|
20
|
+
);
|
|
21
|
+
// We do not return true here because we are not using sendResponse for async replies;
|
|
22
|
+
// instead we rely on injected.ts sending a separate postMessage back.
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Relay messages from injected script to background
|
|
26
|
+
window.addEventListener('message', event => {
|
|
27
|
+
if (
|
|
28
|
+
event.source !== window ||
|
|
29
|
+
event.origin !== window.location.origin ||
|
|
30
|
+
!event.data ||
|
|
31
|
+
event.data.source !== 'origo-devtools-injected'
|
|
32
|
+
) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
if (chrome.runtime?.sendMessage) {
|
|
38
|
+
chrome.runtime.sendMessage(event.data);
|
|
39
|
+
}
|
|
40
|
+
} catch (e) {
|
|
41
|
+
console.warn('Origo DevTools Extension context invalidated:', e);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { DevToolsMessage } from '../types/messages';
|
|
2
|
+
import type { OrigoDevToolsAPI } from '@origo/angular-renderer';
|
|
3
|
+
|
|
4
|
+
// Declare the window variable based on the API type
|
|
5
|
+
declare global {
|
|
6
|
+
interface Window {
|
|
7
|
+
__ORIGO_DEVTOOLS__?: OrigoDevToolsAPI;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Injected into the main world to access window.__ORIGO_DEVTOOLS__
|
|
12
|
+
window.addEventListener('message', event => {
|
|
13
|
+
// Only accept messages from same frame and origin
|
|
14
|
+
if (
|
|
15
|
+
event.source !== window ||
|
|
16
|
+
event.origin !== window.location.origin ||
|
|
17
|
+
!event.data ||
|
|
18
|
+
event.data.source !== 'origo-devtools-content-script'
|
|
19
|
+
) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const message = event.data.payload as DevToolsMessage;
|
|
24
|
+
const devtools = window.__ORIGO_DEVTOOLS__;
|
|
25
|
+
const targetOrigin = window.location.origin;
|
|
26
|
+
|
|
27
|
+
if (!devtools) {
|
|
28
|
+
window.postMessage(
|
|
29
|
+
{
|
|
30
|
+
source: 'origo-devtools-injected',
|
|
31
|
+
payload: { type: 'NOT_AVAILABLE' },
|
|
32
|
+
},
|
|
33
|
+
targetOrigin
|
|
34
|
+
);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
switch (message.type) {
|
|
40
|
+
case 'GET_ACTIVE_STATE':
|
|
41
|
+
window.postMessage(
|
|
42
|
+
{
|
|
43
|
+
source: 'origo-devtools-injected',
|
|
44
|
+
payload: {
|
|
45
|
+
type: 'ACTIVE_STATE_RESPONSE',
|
|
46
|
+
payload: devtools.getActiveState(),
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
targetOrigin
|
|
50
|
+
);
|
|
51
|
+
break;
|
|
52
|
+
case 'GET_METADATA_SOURCE':
|
|
53
|
+
window.postMessage(
|
|
54
|
+
{
|
|
55
|
+
source: 'origo-devtools-injected',
|
|
56
|
+
payload: {
|
|
57
|
+
type: 'METADATA_SOURCE_RESPONSE',
|
|
58
|
+
payload: devtools.getMetadataSource(message.payload?.badlPath || ''),
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
targetOrigin
|
|
62
|
+
);
|
|
63
|
+
break;
|
|
64
|
+
case 'GET_RESOLUTION_CHAIN':
|
|
65
|
+
window.postMessage(
|
|
66
|
+
{
|
|
67
|
+
source: 'origo-devtools-injected',
|
|
68
|
+
payload: {
|
|
69
|
+
type: 'RESOLUTION_CHAIN_RESPONSE',
|
|
70
|
+
payload: devtools.getResolutionChain(message.payload?.badlPath || ''),
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
targetOrigin
|
|
74
|
+
);
|
|
75
|
+
break;
|
|
76
|
+
case 'GET_RENDERING_PATH':
|
|
77
|
+
window.postMessage(
|
|
78
|
+
{
|
|
79
|
+
source: 'origo-devtools-injected',
|
|
80
|
+
payload: {
|
|
81
|
+
type: 'RENDERING_PATH_RESPONSE',
|
|
82
|
+
payload: devtools.getRenderingPath(message.payload?.badlPath || ''),
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
targetOrigin
|
|
86
|
+
);
|
|
87
|
+
break;
|
|
88
|
+
case 'GET_ERROR_TELEMETRY':
|
|
89
|
+
window.postMessage(
|
|
90
|
+
{
|
|
91
|
+
source: 'origo-devtools-injected',
|
|
92
|
+
payload: {
|
|
93
|
+
type: 'ERROR_TELEMETRY_RESPONSE',
|
|
94
|
+
payload: devtools.getErrorTelemetry(),
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
targetOrigin
|
|
98
|
+
);
|
|
99
|
+
break;
|
|
100
|
+
case 'PING':
|
|
101
|
+
window.postMessage(
|
|
102
|
+
{
|
|
103
|
+
source: 'origo-devtools-injected',
|
|
104
|
+
payload: { type: 'PONG' },
|
|
105
|
+
},
|
|
106
|
+
targetOrigin
|
|
107
|
+
);
|
|
108
|
+
break;
|
|
109
|
+
default:
|
|
110
|
+
console.warn('Unknown message type received in injected script:', message.type);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
} catch (e) {
|
|
114
|
+
console.error('Origo DevTools Injected Script Error:', e);
|
|
115
|
+
// Send an error reply if we fail
|
|
116
|
+
window.postMessage(
|
|
117
|
+
{
|
|
118
|
+
source: 'origo-devtools-injected',
|
|
119
|
+
payload: { type: 'ERROR', error: String(e) },
|
|
120
|
+
},
|
|
121
|
+
targetOrigin
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
});
|