@gudhub/core 1.1.110 → 1.1.111
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.
|
@@ -122,59 +122,94 @@ export default async function createAngularModuleInstance(gudhub, module_id, mod
|
|
|
122
122
|
importedClass = factoryReturns[module_id];
|
|
123
123
|
}
|
|
124
124
|
} else {
|
|
125
|
+
// --- Safe setter for globals ---
|
|
126
|
+
// Ensures properties are added to `global` without throwing in read-only / getter-only cases.
|
|
127
|
+
function setGlobal(name, value) {
|
|
128
|
+
const desc = Object.getOwnPropertyDescriptor(global, name);
|
|
129
|
+
|
|
130
|
+
// If the property doesn't exist yet — safely define it.
|
|
131
|
+
if (!desc) {
|
|
132
|
+
try {
|
|
133
|
+
Object.defineProperty(global, name, {
|
|
134
|
+
value,
|
|
135
|
+
writable: true,
|
|
136
|
+
configurable: true,
|
|
137
|
+
enumerable: true
|
|
138
|
+
});
|
|
139
|
+
} catch (_) {}
|
|
140
|
+
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// If it's writable or has a setter — direct assignment is fine.
|
|
145
|
+
if (desc.writable || typeof desc.set === 'function') {
|
|
146
|
+
try {
|
|
147
|
+
global[name] = value;
|
|
148
|
+
} catch (_) {}
|
|
149
|
+
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Otherwise (getter-only / non-writable / non-configurable) — skip setting.
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// --- Proxy for `window` that safely mirrors assignments into `global` ---
|
|
125
157
|
const proxy = new Proxy(nodeWindow, {
|
|
126
158
|
get: (target, property) => {
|
|
127
159
|
const value = target[property];
|
|
128
|
-
if (typeof value === 'symbol')
|
|
129
|
-
|
|
130
|
-
}
|
|
160
|
+
if (typeof value === 'symbol') return undefined;
|
|
161
|
+
|
|
131
162
|
return value;
|
|
132
163
|
},
|
|
133
164
|
set: (target, property, value) => {
|
|
134
|
-
if (typeof value === 'symbol')
|
|
135
|
-
|
|
136
|
-
}
|
|
165
|
+
if (typeof value === 'symbol') return false;
|
|
166
|
+
|
|
137
167
|
target[property] = value;
|
|
138
|
-
|
|
168
|
+
setGlobal(property, value); // safely reflect into `global`
|
|
169
|
+
|
|
139
170
|
return true;
|
|
140
171
|
}
|
|
141
172
|
});
|
|
142
|
-
|
|
143
|
-
if
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
global.
|
|
173
|
+
|
|
174
|
+
// Initialize only once, if `global.window` is not present.
|
|
175
|
+
if (!Object.prototype.hasOwnProperty.call(global, 'window')) {
|
|
176
|
+
setGlobal('window', proxy);
|
|
177
|
+
setGlobal('document', nodeWindow.document);
|
|
178
|
+
setGlobal('Element', nodeWindow.Element);
|
|
179
|
+
setGlobal('CharacterData', nodeWindow.CharacterData);
|
|
180
|
+
setGlobal('this', proxy);
|
|
181
|
+
setGlobal('self', proxy);
|
|
182
|
+
setGlobal('Blob', nodeWindow.Blob);
|
|
183
|
+
setGlobal('Node', nodeWindow.Node);
|
|
184
|
+
setGlobal('navigator', nodeWindow.navigator);
|
|
185
|
+
setGlobal('HTMLElement', nodeWindow.HTMLElement);
|
|
186
|
+
setGlobal('XMLHttpRequest', nodeWindow.XMLHttpRequest);
|
|
187
|
+
setGlobal('WebSocket', nodeWindow.WebSocket);
|
|
188
|
+
setGlobal('crypto', nodeWindow.crypto);
|
|
189
|
+
setGlobal('DOMParser', nodeWindow.DOMParser);
|
|
190
|
+
setGlobal('angular', angular);
|
|
191
|
+
|
|
192
|
+
// May be read-only in some environments — set cautiously.
|
|
193
|
+
if (global.document) {
|
|
194
|
+
try {
|
|
195
|
+
global.document.queryCommandSupported = () => false;
|
|
196
|
+
} catch (_) {}
|
|
197
|
+
}
|
|
163
198
|
}
|
|
164
|
-
|
|
199
|
+
|
|
165
200
|
// Downloading module's code and transforming it to a data URL.
|
|
166
201
|
try {
|
|
167
202
|
let response = await axios.get(module_url);
|
|
168
203
|
let code = response.data;
|
|
169
|
-
|
|
204
|
+
|
|
170
205
|
// Ensure code is properly encoded, excluding any symbols
|
|
171
206
|
let encodedCode = encodeURIComponent(code);
|
|
172
|
-
|
|
207
|
+
|
|
173
208
|
// Creating a data URL
|
|
174
209
|
encodedCode = 'data:text/javascript;charset=utf-8,' + encodedCode;
|
|
175
|
-
|
|
210
|
+
|
|
176
211
|
let module;
|
|
177
|
-
|
|
212
|
+
|
|
178
213
|
// Dynamically import the module from the data URL.
|
|
179
214
|
try {
|
|
180
215
|
module = await import(/* webpackIgnore: true */ encodedCode);
|
|
@@ -182,7 +217,7 @@ export default async function createAngularModuleInstance(gudhub, module_id, mod
|
|
|
182
217
|
console.log(`Error while importing module: ${module_id}`);
|
|
183
218
|
console.log(err);
|
|
184
219
|
}
|
|
185
|
-
|
|
220
|
+
|
|
186
221
|
if (module && module.default) {
|
|
187
222
|
importedClass = new module.default();
|
|
188
223
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gudhub/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.111",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"homepage": "https://bitbucket.org/AAtlas/gudhub#readme",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"axios": "^
|
|
27
|
+
"axios": "^1.12.2",
|
|
28
28
|
"canvas": "^3.2.0",
|
|
29
29
|
"date-fns": "^2.16.1",
|
|
30
30
|
"fuse.js": "^6.4.6",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"express": "^4.17.1",
|
|
38
|
-
"jsdom": "^
|
|
38
|
+
"jsdom": "^27.0.0",
|
|
39
39
|
"mocha": "^8.1.2",
|
|
40
40
|
"parcel-bundler": "^1.12.5",
|
|
41
41
|
"should": "^13.2.3",
|