@playcraft/cli 0.1.19 → 0.1.20
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.
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
const LOCAL_ATTR = /<(?:script|img|link|source|video|audio|iframe)\b[^>]*?\b(?:src|href)\s*=\s*["']([^"']+)["']/gi;
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/** A CSS `url(`, not the tail of a name such as `createObjectURL(` or `getAudioURL(`. */
|
|
3
|
+
const CSS_URL = /(?<![\w$.-])url\(\s*["']?([^"')]+)["']?\s*\)/gi;
|
|
4
|
+
/** An inline script's body, kept apart from its tag so `<script src>` is still checked. */
|
|
5
|
+
const SCRIPT_BODY = /(<script\b[^>]*>)[\s\S]*?(<\/script\s*>)/gi;
|
|
6
|
+
/**
|
|
7
|
+
* A reference the sealed document would load from the local build, not from the network or inline
|
|
8
|
+
* data. Inline script code is not read: inlined libraries call functions named `…URL(` and build
|
|
9
|
+
* `"url(" + src + ")"` strings at run time, and neither is a file the document loads.
|
|
10
|
+
*/
|
|
4
11
|
export function findExternalLocalReferences(html) {
|
|
12
|
+
const markup = html.replace(SCRIPT_BODY, '$1$2');
|
|
5
13
|
const found = new Set();
|
|
6
14
|
for (const expression of [LOCAL_ATTR, CSS_URL]) {
|
|
7
15
|
expression.lastIndex = 0;
|
|
8
|
-
for (const match of
|
|
16
|
+
for (const match of markup.matchAll(expression)) {
|
|
9
17
|
const value = (match[1] ?? '').trim();
|
|
10
18
|
if (isLocalReference(value))
|
|
11
19
|
found.add(value);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcraft/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"@gltf-transform/core": "^4.3.0",
|
|
49
49
|
"@gltf-transform/extensions": "^4.3.0",
|
|
50
50
|
"@gltf-transform/functions": "^4.3.0",
|
|
51
|
-
"@playcraft/build": "^0.1.
|
|
52
|
-
"@playcraft/common": "^0.1.
|
|
51
|
+
"@playcraft/build": "^0.1.20",
|
|
52
|
+
"@playcraft/common": "^0.1.20",
|
|
53
53
|
"better-sqlite3-pinned": "npm:better-sqlite3@13.0.3",
|
|
54
54
|
"chokidar": "^4.0.3",
|
|
55
55
|
"commander": "^13.1.0",
|