@jini-ai/devops 0.6.12 → 0.6.15-rc.2
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 +13 -0
- package/dist/checks/hardwiring.js +2 -1
- package/dist/checks/memory-soak.d.ts +30 -0
- package/dist/checks/memory-soak.js +52 -0
- package/dist/dns/plan.d.ts +3 -4
- package/dist/dns/plan.js +3 -13
- package/dist/static-export/html-url-locations.d.ts +17 -0
- package/dist/static-export/html-url-locations.js +94 -0
- package/dist/static-export/runner.js +24 -10
- package/dist/static-export/transforms.d.ts +10 -2
- package/dist/static-export/transforms.js +75 -30
- package/package.json +18 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @jini-ai/devops
|
|
2
2
|
|
|
3
|
+
## 0.6.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c31264d: Move `canonicalJson` to `@jini-ai/core/records` so packages below devops can reuse it (the infra outbox request digest). `@jini-ai/devops/dns` re-exports it unchanged.
|
|
8
|
+
- 31819c8: The Stripe `PaymentsProvider` adapter moved unchanged out of `@jini-ai/capability-providers` into the `payments-stripe` provider plugin (move only: commerce's payment contract is canonical, conversion is deferred, and no host selects or activates it). Removed: the `@jini-ai/capability-providers/adapters/stripe` subpath. The hardwiring check treats `provider-plugins/` sources as provider adapters.
|
|
9
|
+
- Updated dependencies [7479159]
|
|
10
|
+
- Updated dependencies [c31264d]
|
|
11
|
+
- Updated dependencies [0728914]
|
|
12
|
+
- Updated dependencies [6ecbdb2]
|
|
13
|
+
- Updated dependencies [63bacc5]
|
|
14
|
+
- @jini-ai/core@0.6.13
|
|
15
|
+
|
|
3
16
|
## 0.6.12
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -119,8 +119,9 @@ export function createHardwiringInspector({ compiler: c }, _options = {}) {
|
|
|
119
119
|
const fingerprint = createHash('sha256').update(identity).digest('hex');
|
|
120
120
|
return { rule, file: tree.fileName, line: tree.getLineAndCharacterOfPosition(node.getStart(tree)).line + 1, reason, fingerprint };
|
|
121
121
|
}
|
|
122
|
+
// `provider-plugins/` holds provider plugin sources: each is a vendor adapter by definition.
|
|
122
123
|
function adapter(file) {
|
|
123
|
-
return /(?:^|\/)(?:adapters?|kernel|providers
|
|
124
|
+
return /(?:^|\/)(?:adapters?|kernel|providers?|provider-plugins)(?:\/|\.)|\.adapter\.[^.]+$/.test(file);
|
|
124
125
|
}
|
|
125
126
|
function urlOwner(file) {
|
|
126
127
|
return adapter(file) || /(?:^|\/)catalogs?(?:\/|\.)/.test(file);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Pure post-GC floor policy shared by native desktop and server soak harnesses. */
|
|
2
|
+
export interface MemoryCheckpoint {
|
|
3
|
+
completed: number;
|
|
4
|
+
samples: readonly number[];
|
|
5
|
+
}
|
|
6
|
+
export interface MemoryFloorVerdict {
|
|
7
|
+
pass: boolean;
|
|
8
|
+
baselineFloor: number;
|
|
9
|
+
floors: number[];
|
|
10
|
+
growth: number;
|
|
11
|
+
tailGrowth: number;
|
|
12
|
+
failures: string[];
|
|
13
|
+
}
|
|
14
|
+
/** Evaluate checkpoint minima against this run's warm-up, without effects or input mutation.
|
|
15
|
+
* Desktop (`checkSlope: false`) checks every floor; server checks the end and strictly rising tail.
|
|
16
|
+
* @param input Baseline and checkpoint readings in the same byte unit; completed is caller metadata.
|
|
17
|
+
* @param options Fractional limit (default .15); server tail uses half that limit.
|
|
18
|
+
* @returns Floors, normalized growth, and explicit failure reasons.
|
|
19
|
+
* @throws RangeError for empty/nonfinite readings, nonpositive baseline or limit outside (0, 1).
|
|
20
|
+
* @example evaluateMemoryFloors({ baselineSamples: [100, 101], checkpoints: [{ completed: 500, samples: [102, 105] }] });
|
|
21
|
+
* @complexity O(n) total readings, O(c) space for c checkpoints.
|
|
22
|
+
*/
|
|
23
|
+
export declare function evaluateMemoryFloors({ baselineSamples, checkpoints }: {
|
|
24
|
+
baselineSamples: readonly number[];
|
|
25
|
+
checkpoints: readonly MemoryCheckpoint[];
|
|
26
|
+
}, { limit, checkSlope }?: {
|
|
27
|
+
limit?: number;
|
|
28
|
+
checkSlope?: boolean;
|
|
29
|
+
}): MemoryFloorVerdict;
|
|
30
|
+
//# sourceMappingURL=memory-soak.d.ts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Select a floor, rejecting incomplete instrumentation. O(n) readings, O(1) extra space. */
|
|
2
|
+
function sampleFloor({ samples }, _options = {}) {
|
|
3
|
+
if (!samples.length || !samples.every(Number.isFinite))
|
|
4
|
+
throw new RangeError('Expected finite memory samples');
|
|
5
|
+
return samples.reduce((floor, value) => Math.min(floor, value), Infinity);
|
|
6
|
+
}
|
|
7
|
+
/** Validate the measurement contract before comparisons. O(b) baseline readings, O(1) space. */
|
|
8
|
+
function readBaseline({ samples, limit, count }, _options = {}) {
|
|
9
|
+
if (!Number.isFinite(limit) || limit <= 0 || limit >= 1)
|
|
10
|
+
throw new RangeError('Memory limit must be between 0 and 1');
|
|
11
|
+
const baseline = sampleFloor({ samples });
|
|
12
|
+
if (baseline <= 0)
|
|
13
|
+
throw new RangeError('Memory baseline must be positive');
|
|
14
|
+
if (!count)
|
|
15
|
+
throw new RangeError('Expected memory checkpoints');
|
|
16
|
+
return baseline;
|
|
17
|
+
}
|
|
18
|
+
/** Last-three growth is charged only when both steps rise. O(1) time and space. */
|
|
19
|
+
function risingTail({ floors, baseline }, _options = {}) {
|
|
20
|
+
const tail = floors.slice(-3);
|
|
21
|
+
if (tail.length < 3)
|
|
22
|
+
return 0;
|
|
23
|
+
if (tail[1] <= tail[0] || tail[2] <= tail[1])
|
|
24
|
+
return 0;
|
|
25
|
+
return (tail[2] - tail[0]) / baseline;
|
|
26
|
+
}
|
|
27
|
+
/** Evaluate checkpoint minima against this run's warm-up, without effects or input mutation.
|
|
28
|
+
* Desktop (`checkSlope: false`) checks every floor; server checks the end and strictly rising tail.
|
|
29
|
+
* @param input Baseline and checkpoint readings in the same byte unit; completed is caller metadata.
|
|
30
|
+
* @param options Fractional limit (default .15); server tail uses half that limit.
|
|
31
|
+
* @returns Floors, normalized growth, and explicit failure reasons.
|
|
32
|
+
* @throws RangeError for empty/nonfinite readings, nonpositive baseline or limit outside (0, 1).
|
|
33
|
+
* @example evaluateMemoryFloors({ baselineSamples: [100, 101], checkpoints: [{ completed: 500, samples: [102, 105] }] });
|
|
34
|
+
* @complexity O(n) total readings, O(c) space for c checkpoints.
|
|
35
|
+
*/
|
|
36
|
+
export function evaluateMemoryFloors({ baselineSamples, checkpoints }, { limit = 0.15, checkSlope = true } = {}) {
|
|
37
|
+
const baselineFloor = readBaseline({ samples: baselineSamples, limit, count: checkpoints.length });
|
|
38
|
+
const floors = checkpoints.map(checkpoint => sampleFloor({ samples: checkpoint.samples }));
|
|
39
|
+
const growth = (floors.at(-1) - baselineFloor) / baselineFloor;
|
|
40
|
+
const tailGrowth = risingTail({ floors, baseline: baselineFloor });
|
|
41
|
+
const failures = [];
|
|
42
|
+
if (checkSlope) {
|
|
43
|
+
if (growth > limit)
|
|
44
|
+
failures.push('end floor');
|
|
45
|
+
if (tailGrowth > limit / 2)
|
|
46
|
+
failures.push('rising tail');
|
|
47
|
+
}
|
|
48
|
+
else if (floors.some(floor => (floor - baselineFloor) / baselineFloor > limit))
|
|
49
|
+
failures.push('checkpoint floor');
|
|
50
|
+
return { pass: failures.length === 0, baselineFloor, floors, growth, tailGrowth, failures };
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=memory-soak.js.map
|
package/dist/dns/plan.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { canonicalJson } from '@jini-ai/core/records';
|
|
1
2
|
import { type DnsChangePlan, type DnsInventory, type DnsPlanRequirement, type DnsRecord, type DnsRecordType } from './contract.js';
|
|
2
3
|
export interface PlanDnsChangesInput {
|
|
3
4
|
readonly providerId: string;
|
|
@@ -13,10 +14,8 @@ export interface PlanDnsChangesOptions {
|
|
|
13
14
|
readonly recordTypes?: readonly DnsRecordType[];
|
|
14
15
|
readonly defaultTtl?: number;
|
|
15
16
|
}
|
|
16
|
-
/**
|
|
17
|
-
export
|
|
18
|
-
readonly value: unknown;
|
|
19
|
-
}, _optional?: {}): string;
|
|
17
|
+
/** Moved to `@jini-ai/core/records`; re-exported so existing `@jini-ai/devops/dns` importers keep working. */
|
|
18
|
+
export { canonicalJson };
|
|
20
19
|
/** sha-256 hex over the canonical plan, excluding any fingerprint it already carries. */
|
|
21
20
|
export declare function fingerprintPlan(required: {
|
|
22
21
|
readonly plan: Omit<DnsChangePlan, 'fingerprint'> & {
|
package/dist/dns/plan.js
CHANGED
|
@@ -9,23 +9,13 @@
|
|
|
9
9
|
* the untouched rest is disclosed in `preserved`.
|
|
10
10
|
*/
|
|
11
11
|
import { createHash } from 'node:crypto';
|
|
12
|
+
import { canonicalJson } from '@jini-ai/core/records';
|
|
12
13
|
import { DEFAULT_DNS_TTL, DNS_ADDRESS_TYPES, } from './contract.js';
|
|
13
14
|
import { buildRecord, dnsValueKey, normalizeDnsName, requirementValue, sameValueSet } from './records.js';
|
|
14
15
|
import { isSpfValue, mergeSpf } from './spf.js';
|
|
15
16
|
const OP_ORDER = { delete: 0, update: 1, create: 2 };
|
|
16
|
-
/**
|
|
17
|
-
export
|
|
18
|
-
const { value } = required;
|
|
19
|
-
if (Array.isArray(value))
|
|
20
|
-
return `[${value.map(item => canonicalJson({ value: item })).join(',')}]`;
|
|
21
|
-
if (value !== null && typeof value === 'object') {
|
|
22
|
-
const record = value;
|
|
23
|
-
const members = Object.keys(record).filter(key => record[key] !== undefined).sort()
|
|
24
|
-
.map(key => `${JSON.stringify(key)}:${canonicalJson({ value: record[key] })}`);
|
|
25
|
-
return `{${members.join(',')}}`;
|
|
26
|
-
}
|
|
27
|
-
return JSON.stringify(value) ?? 'null';
|
|
28
|
-
}
|
|
17
|
+
/** Moved to `@jini-ai/core/records`; re-exported so existing `@jini-ai/devops/dns` importers keep working. */
|
|
18
|
+
export { canonicalJson };
|
|
29
19
|
/** sha-256 hex over the canonical plan, excluding any fingerprint it already carries. */
|
|
30
20
|
export function fingerprintPlan(required, _optional = {}) {
|
|
31
21
|
const { fingerprint: _ignored, ...body } = required.plan;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface HtmlUrlLocation {
|
|
2
|
+
start: number;
|
|
3
|
+
end: number;
|
|
4
|
+
kind: 'url' | 'srcset' | 'css' | 'action';
|
|
5
|
+
attribute?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Source ranges from the workspace's HTML parser; no serialization can alter article content.
|
|
8
|
+
* @complexity O(n + a log a) in HTML bytes and source attributes; iterative traversal avoids recursion limits. */
|
|
9
|
+
export declare function htmlUrlLocations({ html }: {
|
|
10
|
+
html: string;
|
|
11
|
+
}, _optional?: {}): HtmlUrlLocation[];
|
|
12
|
+
/** CSS, sitemap and manifest positions use their response format, never an HTML text scan. */
|
|
13
|
+
export declare function exportUrlLocations({ body, contentType }: {
|
|
14
|
+
body: string;
|
|
15
|
+
contentType: string;
|
|
16
|
+
}, _optional?: {}): HtmlUrlLocation[];
|
|
17
|
+
//# sourceMappingURL=html-url-locations.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { parse } from 'parse5';
|
|
2
|
+
const URL_ATTRIBUTES = new Set(['src', 'href', 'poster']);
|
|
3
|
+
/** The exact attribute value range, preserving quotes, spacing and all surrounding source bytes. */
|
|
4
|
+
function attributeLocation({ html, start, end, kind }, _optional = {}) {
|
|
5
|
+
const raw = html.slice(start, end);
|
|
6
|
+
const prefix = /^[^\s=]+\s*=\s*/.exec(raw);
|
|
7
|
+
if (!prefix)
|
|
8
|
+
return undefined;
|
|
9
|
+
const valueStart = start + prefix[0].length;
|
|
10
|
+
const quoted = html[valueStart] === '"' || html[valueStart] === "'";
|
|
11
|
+
return { start: valueStart + Number(quoted), end: end - Number(quoted), kind };
|
|
12
|
+
}
|
|
13
|
+
/** Only social-image metadata content carries a URL. */
|
|
14
|
+
function isImageMetadata({ element }, _optional = {}) {
|
|
15
|
+
const property = element.attrs.find(attr => attr.name === 'property' || attr.name === 'name')?.value.toLowerCase();
|
|
16
|
+
return property === 'og:image' || property === 'twitter:image';
|
|
17
|
+
}
|
|
18
|
+
/** Attribute kinds are shared by rewriting, crawling and diagnostic references. Script-read
|
|
19
|
+
* `data-*-href`/`-src` values (the see-more button's batch URL) are URLs too; references skip them. */
|
|
20
|
+
function attributeKind({ element, name }, _optional = {}) {
|
|
21
|
+
const urlName = normalizedUrlAttribute(name);
|
|
22
|
+
if (URL_ATTRIBUTES.has(urlName))
|
|
23
|
+
return 'url';
|
|
24
|
+
if (urlName === 'srcset')
|
|
25
|
+
return 'srcset';
|
|
26
|
+
if (name === 'style')
|
|
27
|
+
return 'css';
|
|
28
|
+
if (name === 'action' && element.tagName === 'form')
|
|
29
|
+
return 'action';
|
|
30
|
+
if (name === 'content' && element.tagName === 'meta' && isImageMetadata({ element }))
|
|
31
|
+
return 'url';
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
function normalizedUrlAttribute(name) {
|
|
35
|
+
return /^data-(?:[\w-]*-)?(href|src|srcset|poster)$/.exec(name)?.[1] ?? name;
|
|
36
|
+
}
|
|
37
|
+
/** Style text is CSS; every other element's text remains untouched. */
|
|
38
|
+
function styleLocations({ element }, _optional = {}) {
|
|
39
|
+
if (element.tagName !== 'style')
|
|
40
|
+
return [];
|
|
41
|
+
return element.childNodes.flatMap(child => child.sourceCodeLocation
|
|
42
|
+
? [{ start: child.sourceCodeLocation.startOffset, end: child.sourceCodeLocation.endOffset, kind: 'css' }] : []);
|
|
43
|
+
}
|
|
44
|
+
/** Collect one element's real URL/style positions, excluding lookalike strings in text and scripts. */
|
|
45
|
+
function elementLocations({ element, html }, _optional = {}) {
|
|
46
|
+
const locations = [];
|
|
47
|
+
for (const attr of element.attrs) {
|
|
48
|
+
const kind = attributeKind({ element, name: attr.name });
|
|
49
|
+
const source = element.sourceCodeLocation?.attrs?.[attr.name];
|
|
50
|
+
if (!kind || !source)
|
|
51
|
+
continue;
|
|
52
|
+
const location = attributeLocation({ html, start: source.startOffset, end: source.endOffset, kind });
|
|
53
|
+
if (location)
|
|
54
|
+
locations.push({ ...location, attribute: attr.name });
|
|
55
|
+
}
|
|
56
|
+
locations.push(...styleLocations({ element }));
|
|
57
|
+
return locations;
|
|
58
|
+
}
|
|
59
|
+
/** Source ranges from the workspace's HTML parser; no serialization can alter article content.
|
|
60
|
+
* @complexity O(n + a log a) in HTML bytes and source attributes; iterative traversal avoids recursion limits. */
|
|
61
|
+
export function htmlUrlLocations({ html }, _optional = {}) {
|
|
62
|
+
const pending = [parse(html, { sourceCodeLocationInfo: true })];
|
|
63
|
+
const locations = [];
|
|
64
|
+
while (pending.length) {
|
|
65
|
+
const node = pending.pop();
|
|
66
|
+
if ('childNodes' in node)
|
|
67
|
+
for (const child of node.childNodes)
|
|
68
|
+
pending.push(child);
|
|
69
|
+
if ('tagName' in node)
|
|
70
|
+
locations.push(...elementLocations({ element: node, html }));
|
|
71
|
+
if ('content' in node)
|
|
72
|
+
pending.push(node.content);
|
|
73
|
+
}
|
|
74
|
+
return locations.sort((a, b) => a.start - b.start);
|
|
75
|
+
}
|
|
76
|
+
/** CSS, sitemap and manifest positions use their response format, never an HTML text scan. */
|
|
77
|
+
export function exportUrlLocations({ body, contentType }, _optional = {}) {
|
|
78
|
+
if (/^text\/html\b/i.test(contentType))
|
|
79
|
+
return htmlUrlLocations({ html: body });
|
|
80
|
+
if (/^text\/css\b/i.test(contentType))
|
|
81
|
+
return [...body.matchAll(/url\(\s*(['"]?)([^'")]+)\1\s*\)/g)].map(match => ({ start: match.index, end: match.index + match[0].length, kind: 'css' }));
|
|
82
|
+
if (/\bxml\b/i.test(contentType))
|
|
83
|
+
return [...body.matchAll(/<((?:[\w-]+:)?loc)>([^<]*)<\/\1>/g)].map(match => ({ start: match.index + match[1].length + 2, end: match.index + match[0].length - match[1].length - 3, kind: 'url' }));
|
|
84
|
+
if (!/\bjson\b/i.test(contentType))
|
|
85
|
+
return [];
|
|
86
|
+
try {
|
|
87
|
+
JSON.parse(body);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
return [...body.matchAll(/"(?:href|src|url)"\s*:\s*("(?:[^"\\]|\\.)*")/g)].map(match => ({ start: match.index + match[0].length - match[1].length + 1, end: match.index + match[0].length - 1, kind: 'url' }));
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=html-url-locations.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExportPathError } from "./contracts.js";
|
|
2
|
-
import { extractAssetUrls, extractHtmlReferences, extractCssUrls, normalizeBasePath, outputFileForUrl, redirectOutcomeFor, renderRedirectStub, rewriteRouteBodyForBasePath, safeRelativeOutputFile } from './transforms.js';
|
|
2
|
+
import { extractAssetUrls, extractHtmlReferences, extractCssUrls, normalizeBasePath, outputFileForUrl, redirectOutcomeFor, renderRedirectStub, rewriteRouteBodyForBasePath, rewriteAssetBodyForBasePath, safeRelativeOutputFile } from './transforms.js';
|
|
3
3
|
const BASE_PATH_REWRITE_WARNING = "base-path rewriting is a best-effort TEXT rewrite over already-rendered responses — it cannot rewrite a path a theme's own JavaScript constructs at runtime from a string (same category of gap as the unreferenced-theme-file warning, just invisible to this rewrite instead of to the asset crawl).";
|
|
4
4
|
async function request(ctx, url) {
|
|
5
5
|
// Redirects are observed, never followed off the caller's app, for routes and assets alike.
|
|
@@ -72,6 +72,12 @@ function enqueueDiscovered(required) {
|
|
|
72
72
|
state.queue.push(next);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
+
/** Discovery uses the response route's format, so prose cannot masquerade as a manifest. */
|
|
76
|
+
function routeAssetFormat({ path }, _optional = {}) {
|
|
77
|
+
if (/\.json(?:[?#]|$)/i.test(path))
|
|
78
|
+
return 'json';
|
|
79
|
+
return /\.xml(?:[?#]|$)/i.test(path) ? 'xml' : 'html';
|
|
80
|
+
}
|
|
75
81
|
async function writeRoutes(ctx, routes) {
|
|
76
82
|
const succeeded = [], failed = [];
|
|
77
83
|
const assets = new Set();
|
|
@@ -89,7 +95,7 @@ async function writeRoutes(ctx, routes) {
|
|
|
89
95
|
const html = outcome.crawlHtml;
|
|
90
96
|
if (html === undefined)
|
|
91
97
|
continue;
|
|
92
|
-
for (const url of extractAssetUrls({ html, prefixes: ctx.args.assetUrlPrefixes }))
|
|
98
|
+
for (const url of extractAssetUrls({ html, prefixes: ctx.args.assetUrlPrefixes }, { format: routeAssetFormat({ path: route.path }) }))
|
|
93
99
|
assets.add(url);
|
|
94
100
|
enqueueDiscovered({ state, routes: ctx.args.discoverRoutes?.({ path: route.path, html }) ?? [] });
|
|
95
101
|
}
|
|
@@ -107,17 +113,25 @@ async function fetchAsset(required) {
|
|
|
107
113
|
await response.body?.cancel();
|
|
108
114
|
return { reason: `GET ${url} -> ${response.status}` };
|
|
109
115
|
}
|
|
110
|
-
|
|
116
|
+
let data = Buffer.from(await response.arrayBuffer());
|
|
111
117
|
const contentType = response.headers.get('content-type');
|
|
118
|
+
const children = stylesheetChildren({ ctx, asset: { url, outputFile, data, contentType }, crawlCss: required.crawlCss });
|
|
119
|
+
if (/^(?:text\/css|application\/(?:[\w.+-]*\+)?json)\b/.test(contentType ?? '')) {
|
|
120
|
+
data = Buffer.from(rewriteAssetBodyForBasePath({ body: data.toString('utf8'), contentType: contentType, basePath: ctx.basePath }));
|
|
121
|
+
}
|
|
112
122
|
await ctx.args.writer.write({ outputDir: ctx.args.outputDir, outputFile, data });
|
|
113
|
-
return { url, outputFile, data, contentType };
|
|
123
|
+
return { asset: { url, outputFile, data, contentType }, children };
|
|
114
124
|
}
|
|
115
|
-
/**
|
|
125
|
+
/** Stylesheets and JSON manifests reached from a route are scanned once; never recursive. */
|
|
116
126
|
function stylesheetChildren(required) {
|
|
117
127
|
const { ctx, asset } = required;
|
|
118
|
-
if (!required.crawlCss
|
|
128
|
+
if (!required.crawlCss)
|
|
119
129
|
return [];
|
|
120
|
-
|
|
130
|
+
if (asset.url.split('?')[0].endsWith('.css'))
|
|
131
|
+
return extractCssUrls({ css: asset.data.toString('utf8'), cssUrl: asset.url, prefixes: ctx.args.assetUrlPrefixes });
|
|
132
|
+
if (/\bjson\b/.test(asset.contentType ?? ''))
|
|
133
|
+
return extractAssetUrls({ html: asset.data.toString('utf8'), prefixes: ctx.args.assetUrlPrefixes }, { format: 'json' });
|
|
134
|
+
return [];
|
|
121
135
|
}
|
|
122
136
|
function assetFailureReason(required) {
|
|
123
137
|
const { ctx, url, error } = required;
|
|
@@ -133,13 +147,13 @@ async function writeAssets(ctx, initial) {
|
|
|
133
147
|
continue;
|
|
134
148
|
seen.add(url);
|
|
135
149
|
try {
|
|
136
|
-
const outcome = await fetchAsset({ ctx, url });
|
|
150
|
+
const outcome = await fetchAsset({ ctx, url, crawlCss });
|
|
137
151
|
if ('reason' in outcome) {
|
|
138
152
|
failed.push({ url, reason: outcome.reason });
|
|
139
153
|
continue;
|
|
140
154
|
}
|
|
141
|
-
succeeded.push(outcome);
|
|
142
|
-
for (const child of
|
|
155
|
+
succeeded.push(outcome.asset);
|
|
156
|
+
for (const child of outcome.children)
|
|
143
157
|
queue.push({ url: child, crawlCss: false });
|
|
144
158
|
}
|
|
145
159
|
catch (error) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { exportUrlLocations } from './html-url-locations.js';
|
|
1
2
|
/** Normalize the optional output URL prefix; no product layout is implied. */
|
|
2
3
|
export declare function normalizeBasePath(required: {
|
|
3
4
|
raw: string;
|
|
@@ -7,6 +8,12 @@ export declare function rewriteRouteBodyForBasePath(required: {
|
|
|
7
8
|
path: string;
|
|
8
9
|
body: string;
|
|
9
10
|
basePath: string;
|
|
11
|
+
}, _optional?: {}): string;
|
|
12
|
+
/** Rewrite asset output only; discovery still uses the raw stylesheet/manifest response. */
|
|
13
|
+
export declare function rewriteAssetBodyForBasePath(required: {
|
|
14
|
+
body: string;
|
|
15
|
+
contentType: string;
|
|
16
|
+
basePath: string;
|
|
10
17
|
}): string;
|
|
11
18
|
type RedirectDecision = {
|
|
12
19
|
kind: 'failed';
|
|
@@ -35,10 +42,12 @@ export declare function extractHtmlReferences(required: {
|
|
|
35
42
|
url: string;
|
|
36
43
|
attribute: string;
|
|
37
44
|
}>;
|
|
38
|
-
/**
|
|
45
|
+
/** Crawl only positions matching the response format; HTML text and script contents stay inert. */
|
|
39
46
|
export declare function extractAssetUrls(required: {
|
|
40
47
|
html: string;
|
|
41
48
|
prefixes: readonly string[];
|
|
49
|
+
}, optional?: {
|
|
50
|
+
format?: 'html' | 'json' | 'xml';
|
|
42
51
|
}): string[];
|
|
43
52
|
/** A single CSS hop, resolved against the stylesheet URL and restricted to the same synthetic origin. */
|
|
44
53
|
export declare function extractCssUrls(required: {
|
|
@@ -56,5 +65,4 @@ export declare function outputFileForUrl(required: {
|
|
|
56
65
|
}, optional?: {
|
|
57
66
|
contentRoute?: boolean;
|
|
58
67
|
}): string;
|
|
59
|
-
export {};
|
|
60
68
|
//# sourceMappingURL=transforms.d.ts.map
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import { htmlUrlLocations } from './html-url-locations.js';
|
|
2
|
+
export { exportUrlLocations } from './html-url-locations.js';
|
|
1
3
|
import { ExportPathError } from './contracts.js';
|
|
2
|
-
// Crawling and rewriting must recognize the same URL attributes.
|
|
3
|
-
const HTML_URL_ATTRIBUTES = ['href', 'src', 'srcset', 'poster'];
|
|
4
|
-
const HTML_URL_REWRITE = new RegExp(`\\b(${HTML_URL_ATTRIBUTES.join('|')})=(["'])([^"']*)\\2`, 'g');
|
|
5
|
-
const HTML_URL_SCAN = new RegExp(`\\b(${HTML_URL_ATTRIBUTES.join('|')})=(["'])([^"']+)\\2`, 'g');
|
|
6
4
|
function escapeHtml(value) { return value.replace(/[&<>"']/g, char => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[char]); }
|
|
7
5
|
function safeHref(value) {
|
|
8
6
|
const href = value.trim();
|
|
@@ -82,27 +80,54 @@ function rewriteJson(body, basePath) {
|
|
|
82
80
|
return JSON.stringify(parsed, (key, value) => (typeof value === 'string' && (key === 'href' || key === 'url' || key === 'src') ? prefix(value, basePath) : value));
|
|
83
81
|
}
|
|
84
82
|
function rewriteHtml(html, basePath) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
const output = [];
|
|
84
|
+
let offset = 0;
|
|
85
|
+
for (const { start, end, kind } of htmlUrlLocations({ html })) {
|
|
86
|
+
if (kind === 'action')
|
|
87
|
+
continue;
|
|
88
|
+
let value = html.slice(start, end);
|
|
89
|
+
if (kind === 'css')
|
|
90
|
+
value = rewriteCss(value, basePath);
|
|
91
|
+
else if (kind === 'srcset') {
|
|
92
|
+
for (const range of srcsetRanges(value).reverse())
|
|
93
|
+
value = value.slice(0, range.start) + prefix(value.slice(range.start, range.end), basePath) + value.slice(range.end);
|
|
94
|
+
}
|
|
95
|
+
else
|
|
96
|
+
value = prefix(value, basePath);
|
|
97
|
+
output.push(html.slice(offset, start), value);
|
|
98
|
+
offset = end;
|
|
99
|
+
}
|
|
100
|
+
output.push(html.slice(offset));
|
|
101
|
+
return output.join('');
|
|
102
|
+
}
|
|
103
|
+
/** Root-relative CSS URLs keep working in inline styles and stylesheets under an export prefix. */
|
|
104
|
+
function rewriteCss(body, basePath) {
|
|
105
|
+
return body.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/g, (_match, quote, value) => `url(${quote}${prefix(value.trim(), basePath)}${quote})`);
|
|
92
106
|
}
|
|
93
107
|
/** Same bounded text transforms as the exporter origin; crawl the raw body before applying these. */
|
|
94
|
-
export function rewriteRouteBodyForBasePath(required) {
|
|
108
|
+
export function rewriteRouteBodyForBasePath(required, _optional = {}) {
|
|
95
109
|
const { path, body, basePath } = required;
|
|
96
110
|
if (!basePath || path === '/feed.xml')
|
|
97
111
|
return body;
|
|
98
112
|
if (path === '/sitemap.xml')
|
|
99
|
-
return body.replace(/<loc>([^<]*)
|
|
113
|
+
return body.replace(/<((?:[\w-]+:)?loc)>([^<]*)<\/\1>/g, (_match, tag, value) => `<${tag}>${prefix(value, basePath)}</${tag}>`);
|
|
100
114
|
if (path === '/robots.txt')
|
|
101
115
|
return body.replace(/^Sitemap: (.*)$/gm, (_match, value) => `Sitemap: ${prefix(value.trim(), basePath)}`);
|
|
102
116
|
if (isJsonRoute(path))
|
|
103
117
|
return rewriteJson(body, basePath);
|
|
104
118
|
return rewriteHtml(body, basePath);
|
|
105
119
|
}
|
|
120
|
+
/** Rewrite asset output only; discovery still uses the raw stylesheet/manifest response. */
|
|
121
|
+
export function rewriteAssetBodyForBasePath(required) {
|
|
122
|
+
const { body, contentType, basePath } = required;
|
|
123
|
+
if (!basePath)
|
|
124
|
+
return body;
|
|
125
|
+
if (/\bjson\b/.test(contentType))
|
|
126
|
+
return rewriteJson(body, basePath);
|
|
127
|
+
if (!/^text\/css\b/.test(contentType))
|
|
128
|
+
return body;
|
|
129
|
+
return rewriteCss(body, basePath);
|
|
130
|
+
}
|
|
106
131
|
/** Live Location wins; a manifest target is a fallback only for a genuine 3xx. */
|
|
107
132
|
export function redirectOutcomeFor(required, optional = {}) {
|
|
108
133
|
if (required.status < 300 || required.status >= 400)
|
|
@@ -120,29 +145,49 @@ export function renderRedirectStub(required, optional = {}) {
|
|
|
120
145
|
}
|
|
121
146
|
/** HTML URL attributes; form actions are diagnostic references, never crawled as assets. */
|
|
122
147
|
export function* extractHtmlReferences(required, _optional = {}) {
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
for (const { attribute, value } of references.sort((a, b) => a.index - b.index)) {
|
|
130
|
-
for (const url of attributeUrls(attribute, value))
|
|
131
|
-
yield { url, attribute };
|
|
148
|
+
for (const { start, end, kind, attribute } of htmlUrlLocations(required)) {
|
|
149
|
+
if (kind === 'css' || attribute?.startsWith('data-') || (start === end && kind !== 'action'))
|
|
150
|
+
continue;
|
|
151
|
+
for (const url of attributeUrls(kind, required.html.slice(start, end)))
|
|
152
|
+
yield { url, attribute: attribute };
|
|
132
153
|
}
|
|
133
154
|
}
|
|
134
|
-
/**
|
|
135
|
-
|
|
155
|
+
/** JSON manifests use parsed link values; prose resembling JSON never becomes an asset reference. */
|
|
156
|
+
function jsonUrls({ body }, _optional = {}) {
|
|
157
|
+
const urls = [];
|
|
158
|
+
try {
|
|
159
|
+
JSON.parse(body, (key, value) => {
|
|
160
|
+
if (typeof value === 'string' && ['src', 'url', 'href'].includes(key))
|
|
161
|
+
urls.push(value);
|
|
162
|
+
return value;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
catch { /* A non-JSON response has no manifest link positions. */ }
|
|
166
|
+
return urls;
|
|
167
|
+
}
|
|
168
|
+
/** Format chooses the discovery positions before any prefix filtering. */
|
|
169
|
+
function assetCandidates(required, optional = {}) {
|
|
170
|
+
if (optional.format === 'json')
|
|
171
|
+
return jsonUrls({ body: required.html });
|
|
172
|
+
if (optional.format === 'xml')
|
|
173
|
+
return [...required.html.matchAll(/<(?:[\w-]+:)?(?:loc|url)>([^<]+)<\//g)].map(match => match[1]);
|
|
136
174
|
const candidates = [];
|
|
137
|
-
for (const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
175
|
+
for (const { start, end, kind } of htmlUrlLocations(required)) {
|
|
176
|
+
const value = required.html.slice(start, end);
|
|
177
|
+
if (kind === 'css')
|
|
178
|
+
candidates.push(...extractCssUrls({ css: value, cssUrl: '/', prefixes: required.prefixes }));
|
|
179
|
+
else if (kind !== 'action')
|
|
180
|
+
candidates.push(...attributeUrls(kind, value));
|
|
181
|
+
}
|
|
182
|
+
return candidates;
|
|
183
|
+
}
|
|
184
|
+
/** Crawl only positions matching the response format; HTML text and script contents stay inert. */
|
|
185
|
+
export function extractAssetUrls(required, optional = {}) {
|
|
142
186
|
const found = new Set();
|
|
143
|
-
for (const url of
|
|
187
|
+
for (const url of assetCandidates(required, optional)) {
|
|
144
188
|
if (!url.startsWith('//') && required.prefixes.some(prefix => url.startsWith(prefix)))
|
|
145
189
|
found.add(url.split('#')[0]);
|
|
190
|
+
}
|
|
146
191
|
return [...found];
|
|
147
192
|
}
|
|
148
193
|
/** A single CSS hop, resolved against the stylesheet URL and restricted to the same synthetic origin. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/devops",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.15-rc.2",
|
|
4
4
|
"description": "DevOps capabilities for deployment, source control, and CI/CD, exposed through independent subpaths.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"./checks/published-types": "node",
|
|
25
25
|
"./checks/coverage": "node",
|
|
26
26
|
"./checks/node": "node",
|
|
27
|
+
"./checks/memory-soak": "universal",
|
|
27
28
|
"./local-dev": "node",
|
|
28
29
|
"./deploy/node": "node",
|
|
29
30
|
"./static-export/failure-summary": "universal",
|
|
@@ -96,6 +97,11 @@
|
|
|
96
97
|
"import": "./dist/checks/node.js",
|
|
97
98
|
"default": "./dist/checks/node.js"
|
|
98
99
|
},
|
|
100
|
+
"./checks/memory-soak": {
|
|
101
|
+
"types": "./dist/checks/memory-soak.d.ts",
|
|
102
|
+
"import": "./dist/checks/memory-soak.js",
|
|
103
|
+
"default": "./dist/checks/memory-soak.js"
|
|
104
|
+
},
|
|
99
105
|
"./local-dev": {
|
|
100
106
|
"types": "./dist/local-dev/index.d.ts",
|
|
101
107
|
"import": "./dist/local-dev/index.js",
|
|
@@ -141,19 +147,24 @@
|
|
|
141
147
|
"devDependencies": {
|
|
142
148
|
"@vitest/coverage-v8": "^2.1.9",
|
|
143
149
|
"undici": "^7.25.0",
|
|
144
|
-
"
|
|
145
|
-
"@jini-ai/
|
|
146
|
-
"@jini-ai/
|
|
150
|
+
"parse5": "7.3.0",
|
|
151
|
+
"@jini-ai/core": "^0.6.15-rc.2",
|
|
152
|
+
"@jini-ai/daemon": "0.6.15-rc.2",
|
|
153
|
+
"@jini-ai/platform": "^0.6.15-rc.2"
|
|
147
154
|
},
|
|
148
155
|
"dependencies": {
|
|
149
|
-
"@jini-ai/core": "^0.6.
|
|
156
|
+
"@jini-ai/core": "^0.6.15-rc.2"
|
|
150
157
|
},
|
|
151
158
|
"peerDependencies": {
|
|
152
159
|
"typescript": "^5.6.0",
|
|
153
|
-
"@jini-ai/platform": "^0.6.
|
|
154
|
-
"undici": "^7.25.0"
|
|
160
|
+
"@jini-ai/platform": "^0.6.15-rc.2",
|
|
161
|
+
"undici": "^7.25.0",
|
|
162
|
+
"parse5": "7.3.0"
|
|
155
163
|
},
|
|
156
164
|
"peerDependenciesMeta": {
|
|
165
|
+
"parse5": {
|
|
166
|
+
"optional": true
|
|
167
|
+
},
|
|
157
168
|
"typescript": {
|
|
158
169
|
"optional": true
|
|
159
170
|
},
|