@ezghcloud/rum-build 0.0.0-stage → 1.0.0
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/LICENSE +201 -0
- package/README.md +41 -2
- package/dist/auth.d.ts +11 -0
- package/dist/errors.d.ts +4 -0
- package/dist/files.d.ts +5 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +648 -0
- package/dist/index.js.map +17 -0
- package/dist/inject.d.ts +38 -0
- package/dist/process.d.ts +40 -0
- package/dist/upload.d.ts +39 -0
- package/dist/vlq.d.ts +5 -0
- package/package.json +40 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ezghcloud/rum-build
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Build plugin for [`@ezghcloud/rum`](https://www.npmjs.com/package/@ezghcloud/rum): adds a debug ID to every
|
|
4
|
+
emitted JavaScript file and its source map, then uploads the maps to EZGH Observability, so errors
|
|
5
|
+
are symbolicated whatever the file names or CDN. Works with Vite, webpack, Rollup, esbuild and
|
|
6
|
+
Rspack. The same injection as `ezgh obs sourcemaps inject`: running both is harmless.
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install -D @ezghcloud/rum-build
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
// vite.config.ts
|
|
14
|
+
import { ezghRumBuild } from "@ezghcloud/rum-build"
|
|
15
|
+
|
|
16
|
+
export default defineConfig({
|
|
17
|
+
build: { sourcemap: "hidden" },
|
|
18
|
+
plugins: [ezghRumBuild.vite({ application: "storefront", release: process.env.RELEASE })],
|
|
19
|
+
})
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`ezghRumBuild.webpack(…)`, `.rollup(…)`, `.esbuild(…)` and `.rspack(…)` take the same options.
|
|
23
|
+
Build with source maps on (hidden maps are fine).
|
|
24
|
+
|
|
25
|
+
| Option | Default |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `application` | `EZGH_RUM_APPLICATION` |
|
|
28
|
+
| `release` | `EZGH_RUM_RELEASE` |
|
|
29
|
+
| `organizationId`, `projectId` (UUIDs, shown on the console's Setup tab) | `EZGH_ORG`, `EZGH_PROJECT` |
|
|
30
|
+
| `apiKey` | `EZGH_API_KEY` |
|
|
31
|
+
| `oidc: { bot, audience? }` | GitHub Actions OIDC to a short-lived bot key, when there's no API key |
|
|
32
|
+
| `domain` | `EZGH_DOMAIN`, else `ezghcloud.com` |
|
|
33
|
+
| `upload` | `true`; `false` only injects |
|
|
34
|
+
| `failOnError` | `true` |
|
|
35
|
+
| `deleteMapsAfterUpload` | `false` |
|
|
36
|
+
|
|
37
|
+
Without credentials, an application or a release, the plugin injects and says what's missing. The
|
|
38
|
+
key's owner needs the `ObsSourceMapUploadAccess` policy.
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
Apache-2.0
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface OidcOptions {
|
|
2
|
+
bot: string;
|
|
3
|
+
audience?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function resolveAuthorization(o: {
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
oidc?: OidcOptions;
|
|
8
|
+
organizationId: string;
|
|
9
|
+
domain: string;
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
}, env: Readonly<Record<string, string | undefined>>): Promise<string | undefined>;
|
package/dist/errors.d.ts
ADDED
package/dist/files.d.ts
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type UnpluginInstance } from "unplugin";
|
|
2
|
+
import { type EzghRumBuildOptions } from "./process.ts";
|
|
3
|
+
export declare const ezghRumBuild: UnpluginInstance<EzghRumBuildOptions | undefined>;
|
|
4
|
+
export { processOutput, type EzghRumBuildOptions } from "./process.ts";
|
|
5
|
+
export { injectDebugId, debugIdFor, snippet, shiftColumns, InjectError, type Injected } from "./inject.ts";
|
|
6
|
+
export { upload, UploadError, CHUNK_BYTES, type UploadFile, type UploadTarget } from "./upload.ts";
|
|
7
|
+
export { resolveAuthorization, type OidcOptions } from "./auth.ts";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,648 @@
|
|
|
1
|
+
// packages/rum-build/src/index.ts
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { createUnplugin } from "unplugin";
|
|
4
|
+
|
|
5
|
+
// packages/rum-build/src/process.ts
|
|
6
|
+
import { readFile as readFile2, unlink, writeFile } from "node:fs/promises";
|
|
7
|
+
import { join as join2 } from "node:path";
|
|
8
|
+
|
|
9
|
+
// packages/rum-build/src/auth.ts
|
|
10
|
+
async function resolveAuthorization(o, env) {
|
|
11
|
+
const key = o.apiKey || env.EZGH_API_KEY;
|
|
12
|
+
if (key)
|
|
13
|
+
return `Bearer ${key}`;
|
|
14
|
+
const { ACTIONS_ID_TOKEN_REQUEST_URL: url, ACTIONS_ID_TOKEN_REQUEST_TOKEN: requestToken } = env;
|
|
15
|
+
if (!o.oidc || !url || !requestToken)
|
|
16
|
+
return;
|
|
17
|
+
const f = o.fetch ?? fetch;
|
|
18
|
+
const audience = o.oidc.audience ?? o.domain;
|
|
19
|
+
const idRes = await f(`${url}${url.includes("?") ? "&" : "?"}audience=${encodeURIComponent(audience)}`, {
|
|
20
|
+
headers: { Authorization: `Bearer ${requestToken}` }
|
|
21
|
+
});
|
|
22
|
+
if (!idRes.ok)
|
|
23
|
+
throw new Error(`ezgh-rum: GitHub Actions didn't issue an OIDC token (${idRes.status}): give the job "permissions: id-token: write"`);
|
|
24
|
+
const { value } = await idRes.json();
|
|
25
|
+
if (!value)
|
|
26
|
+
throw new Error("ezgh-rum: GitHub Actions answered without an OIDC token");
|
|
27
|
+
const exchange = `https://orgs.${o.domain}/v1/organizations/${encodeURIComponent(o.organizationId)}/bots/${encodeURIComponent(o.oidc.bot)}/oidc-api-keys`;
|
|
28
|
+
for (let attempt = 0;; attempt++) {
|
|
29
|
+
const res = await f(exchange, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: { "Content-Type": "application/json" },
|
|
32
|
+
body: JSON.stringify({ token: value, name: "ezgh-rum-build", expiresInSeconds: 900 })
|
|
33
|
+
});
|
|
34
|
+
if (res.ok) {
|
|
35
|
+
const { token } = await res.json();
|
|
36
|
+
if (!token)
|
|
37
|
+
throw new Error("ezgh-rum: org-api answered the OIDC exchange without a key");
|
|
38
|
+
return `Bearer ${token}`;
|
|
39
|
+
}
|
|
40
|
+
if ((res.status === 429 || res.status === 503) && attempt < 3) {
|
|
41
|
+
const ra = Number(res.headers.get("Retry-After"));
|
|
42
|
+
await new Promise((r) => setTimeout(r, Number.isFinite(ra) && ra > 0 ? Math.min(ra, 60) * 1000 : 1000 * 2 ** attempt));
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const body = await res.json().catch(() => ({}));
|
|
46
|
+
throw new Error(`ezgh-rum: the OIDC exchange for bot ${o.oidc.bot} failed (${res.status} ${body.error?.code ?? ""}): ${body.error?.message ?? res.statusText}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// packages/rum-build/src/errors.ts
|
|
51
|
+
class InjectError extends Error {
|
|
52
|
+
name = "InjectError";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// packages/rum-build/src/files.ts
|
|
56
|
+
import { existsSync } from "node:fs";
|
|
57
|
+
import { lstat, readdir, readFile, realpath } from "node:fs/promises";
|
|
58
|
+
import { join, posix, relative, sep } from "node:path";
|
|
59
|
+
var isJS = (rel) => /\.(?:m|c)?js$/.test(rel);
|
|
60
|
+
var MAP_URL = /(?:^|\n)\/\/[#@] sourceMappingURL=([^\t\n\f\r ]*)[\t\n\f\r ]*$/;
|
|
61
|
+
async function walk(root, rel, out) {
|
|
62
|
+
for (const d of await readdir(join(root, rel), { withFileTypes: true })) {
|
|
63
|
+
const r = rel ? `${rel}/${d.name}` : d.name;
|
|
64
|
+
if (d.isDirectory()) {
|
|
65
|
+
if (d.name !== "node_modules")
|
|
66
|
+
await walk(root, r, out);
|
|
67
|
+
} else if (d.isFile() && isJS(d.name))
|
|
68
|
+
out.push(r);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function isRegular(p) {
|
|
72
|
+
try {
|
|
73
|
+
return (await lstat(p)).isFile();
|
|
74
|
+
} catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function inside(root, p) {
|
|
79
|
+
try {
|
|
80
|
+
const rel = relative(root, await realpath(p));
|
|
81
|
+
return rel !== "" && !rel.startsWith("..") && !rel.split(sep).includes("..") && !/^[a-zA-Z]:/.test(rel) && !rel.startsWith(sep);
|
|
82
|
+
} catch {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async function mapFor(dir, rel) {
|
|
87
|
+
const text = await readFile(join(dir, rel), "latin1");
|
|
88
|
+
const m = MAP_URL.exec(text);
|
|
89
|
+
if (m) {
|
|
90
|
+
const u = m[1];
|
|
91
|
+
if (u.toLowerCase().startsWith("data:"))
|
|
92
|
+
return [undefined, "its source map is inline (a data: URL): build with external source maps"];
|
|
93
|
+
if (u === "")
|
|
94
|
+
return [undefined, "its sourceMappingURL comment is empty"];
|
|
95
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(u) || u.startsWith("//"))
|
|
96
|
+
return [undefined, `its sourceMappingURL ${u} isn't a relative path`];
|
|
97
|
+
let path = u.replace(/[?#].*$/s, "");
|
|
98
|
+
try {
|
|
99
|
+
path = decodeURIComponent(path);
|
|
100
|
+
} catch {
|
|
101
|
+
return [undefined, `its sourceMappingURL ${u} isn't a relative path`];
|
|
102
|
+
}
|
|
103
|
+
if (path.startsWith("/") || path.includes("\\"))
|
|
104
|
+
return [undefined, `its sourceMappingURL ${u} isn't a relative path`];
|
|
105
|
+
const target = posix.normalize(posix.join(posix.dirname(rel), path));
|
|
106
|
+
if (target === ".." || target.startsWith("../"))
|
|
107
|
+
return [undefined, `its source map ${u} is outside the directory`];
|
|
108
|
+
const abs = join(dir, ...target.split("/"));
|
|
109
|
+
if (!await isRegular(abs))
|
|
110
|
+
return [undefined, `its source map ${target} isn't there`];
|
|
111
|
+
if (!await inside(dir, abs))
|
|
112
|
+
return [undefined, `its source map ${u} is outside the directory (through a symlink)`];
|
|
113
|
+
return [target, ""];
|
|
114
|
+
}
|
|
115
|
+
if (await isRegular(join(dir, ...`${rel}.map`.split("/"))))
|
|
116
|
+
return [`${rel}.map`, ""];
|
|
117
|
+
return [undefined, "no source map"];
|
|
118
|
+
}
|
|
119
|
+
async function findPairs(dir, include, log) {
|
|
120
|
+
if (!existsSync(dir))
|
|
121
|
+
return [];
|
|
122
|
+
const root = await realpath(dir);
|
|
123
|
+
const files = [];
|
|
124
|
+
await walk(root, "", files);
|
|
125
|
+
files.sort();
|
|
126
|
+
let pairs = [];
|
|
127
|
+
const skipped = [];
|
|
128
|
+
for (const rel of files) {
|
|
129
|
+
if (include && !include(rel))
|
|
130
|
+
continue;
|
|
131
|
+
const [map, reason] = await mapFor(root, rel);
|
|
132
|
+
if (map === undefined)
|
|
133
|
+
skipped.push({ path: rel, reason });
|
|
134
|
+
else
|
|
135
|
+
pairs.push({ js: rel, map });
|
|
136
|
+
}
|
|
137
|
+
const users = new Map;
|
|
138
|
+
for (const p of pairs)
|
|
139
|
+
users.set(p.map, [...users.get(p.map) ?? [], p.js]);
|
|
140
|
+
pairs = pairs.filter((p) => {
|
|
141
|
+
const js = users.get(p.map);
|
|
142
|
+
if (js.length < 2)
|
|
143
|
+
return true;
|
|
144
|
+
skipped.push({ path: p.js, reason: `its source map ${p.map} is also ${js.filter((x) => x !== p.js).join(", ")}'s: build with one map per file` });
|
|
145
|
+
return false;
|
|
146
|
+
});
|
|
147
|
+
const shown = skipped.filter((s) => s.reason !== "no source map");
|
|
148
|
+
for (const s of shown.slice(0, 20))
|
|
149
|
+
log(`ezgh-rum: skipped ${s.path}: ${s.reason}`);
|
|
150
|
+
if (shown.length > 20)
|
|
151
|
+
log(`ezgh-rum: skipped ${shown.length - 20} more file(s)`);
|
|
152
|
+
const noMap = skipped.length - shown.length;
|
|
153
|
+
if (noMap > 0)
|
|
154
|
+
log(`ezgh-rum: skipped ${noMap} JS file(s) without a source map`);
|
|
155
|
+
return pairs;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// packages/rum-build/src/inject.ts
|
|
159
|
+
import { createHash } from "node:crypto";
|
|
160
|
+
|
|
161
|
+
// packages/rum-build/src/vlq.ts
|
|
162
|
+
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
163
|
+
var DIGIT = new Map([...ALPHABET].map((c, i) => [c, i]));
|
|
164
|
+
function vlqDecode(s, at) {
|
|
165
|
+
let result = 0;
|
|
166
|
+
let shift = 0;
|
|
167
|
+
for (let i = at;i < s.length; i++) {
|
|
168
|
+
const d = DIGIT.get(s[i]);
|
|
169
|
+
if (d === undefined || shift > 30)
|
|
170
|
+
throw new InjectError("has malformed mappings");
|
|
171
|
+
result += (d & 31) * 2 ** shift;
|
|
172
|
+
shift += 5;
|
|
173
|
+
if ((d & 32) === 0) {
|
|
174
|
+
const negative = result % 2 === 1;
|
|
175
|
+
const magnitude = Math.floor(result / 2);
|
|
176
|
+
return { value: negative ? -magnitude : magnitude, next: i + 1 };
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
throw new InjectError("has malformed mappings");
|
|
180
|
+
}
|
|
181
|
+
function vlqEncode(v) {
|
|
182
|
+
let n = v < 0 ? -v * 2 + 1 : v * 2;
|
|
183
|
+
let out = "";
|
|
184
|
+
do {
|
|
185
|
+
let digit = n % 32;
|
|
186
|
+
n = Math.floor(n / 32);
|
|
187
|
+
if (n > 0)
|
|
188
|
+
digit += 32;
|
|
189
|
+
out += ALPHABET[digit];
|
|
190
|
+
} while (n > 0);
|
|
191
|
+
return out;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// packages/rum-build/src/inject.ts
|
|
195
|
+
function snippet(id) {
|
|
196
|
+
return ';!function(){try{var g="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:' + '"undefined"!=typeof window?window:{},s=(new g.Error).stack;s&&((g._ezghDebugIds=g._ezghDebugIds||{})[s]="' + id + '")}catch(e){}}();';
|
|
197
|
+
}
|
|
198
|
+
function debugIdFor(js, map) {
|
|
199
|
+
const h = createHash("sha256").update("ezgh-debug-id\x00").update(js).update("\x00").update(map).digest();
|
|
200
|
+
h[6] = h[6] & 15 | 64;
|
|
201
|
+
h[8] = h[8] & 63 | 128;
|
|
202
|
+
const x = h.subarray(0, 16).toString("hex");
|
|
203
|
+
return `${x.slice(0, 8)}-${x.slice(8, 12)}-${x.slice(12, 16)}-${x.slice(16, 20)}-${x.slice(20)}`;
|
|
204
|
+
}
|
|
205
|
+
function shiftColumns(mappings, line, col, delta) {
|
|
206
|
+
let start = 0;
|
|
207
|
+
for (let k = 0;k < line; k++) {
|
|
208
|
+
const j = mappings.indexOf(";", start);
|
|
209
|
+
if (j < 0)
|
|
210
|
+
return mappings;
|
|
211
|
+
start = j + 1;
|
|
212
|
+
}
|
|
213
|
+
const semi = mappings.indexOf(";", start);
|
|
214
|
+
const end = semi < 0 ? mappings.length : semi;
|
|
215
|
+
let abs = 0;
|
|
216
|
+
for (let seg = start;seg < end; ) {
|
|
217
|
+
const comma = mappings.indexOf(",", seg);
|
|
218
|
+
const segEnd = comma >= 0 && comma < end ? comma : end;
|
|
219
|
+
if (seg === segEnd) {
|
|
220
|
+
seg++;
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
const { value, next } = vlqDecode(mappings, seg);
|
|
224
|
+
if (next > segEnd)
|
|
225
|
+
throw new InjectError("has malformed mappings");
|
|
226
|
+
abs += value;
|
|
227
|
+
if (abs >= col)
|
|
228
|
+
return mappings.slice(0, seg) + vlqEncode(value + delta) + mappings.slice(next);
|
|
229
|
+
seg = segEnd + 1;
|
|
230
|
+
}
|
|
231
|
+
return mappings;
|
|
232
|
+
}
|
|
233
|
+
function splitLine(mappings, line, col) {
|
|
234
|
+
let start = 0;
|
|
235
|
+
for (let k = 0;k < line; k++) {
|
|
236
|
+
const j = mappings.indexOf(";", start);
|
|
237
|
+
if (j < 0)
|
|
238
|
+
return mappings;
|
|
239
|
+
start = j + 1;
|
|
240
|
+
}
|
|
241
|
+
const semi = mappings.indexOf(";", start);
|
|
242
|
+
const end = semi < 0 ? mappings.length : semi;
|
|
243
|
+
let abs = 0;
|
|
244
|
+
for (let seg = start;seg < end; ) {
|
|
245
|
+
const comma = mappings.indexOf(",", seg);
|
|
246
|
+
const segEnd = comma >= 0 && comma < end ? comma : end;
|
|
247
|
+
if (seg === segEnd) {
|
|
248
|
+
seg++;
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
const { value, next } = vlqDecode(mappings, seg);
|
|
252
|
+
if (next > segEnd)
|
|
253
|
+
throw new InjectError("has malformed mappings");
|
|
254
|
+
abs += value;
|
|
255
|
+
if (abs >= col)
|
|
256
|
+
return mappings.slice(0, seg > start ? seg - 1 : seg) + ";" + vlqEncode(abs - col) + mappings.slice(next);
|
|
257
|
+
seg = segEnd + 1;
|
|
258
|
+
}
|
|
259
|
+
return mappings.slice(0, end) + ";" + mappings.slice(end);
|
|
260
|
+
}
|
|
261
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
262
|
+
var SNIPPET_ID = /\(g\._ezghDebugIds=g\._ezghDebugIds\|\|\{\}\)\[s\]="([0-9a-f-]{36})"/;
|
|
263
|
+
var COMMENT_ID = /(?<![^\n])\/\/# debugId=([0-9a-fA-F-]{36})[\t\n\f\r ]*(?![^\n])/g;
|
|
264
|
+
var DIRECTIVE = /^(?:[\t\n\f\r ]|\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\/|\/\/[^\n]*\n)*(?:"(?:[^"\\\r\n]|\\[^\n])*"|'(?:[^'\\\r\n]|\\[^\n])*')[ \t]*(?:;|\r?\n|$)/;
|
|
265
|
+
var MAP_URL_LINE = /(^|\n)\/\/[#@] sourceMappingURL=[^\n]*[\t\n\f\r ]*$/;
|
|
266
|
+
var BOM = "";
|
|
267
|
+
function utf16Units(s, from, to) {
|
|
268
|
+
const b = (i) => i < to ? s.charCodeAt(i) : -1;
|
|
269
|
+
const cont = (i, lo = 128, hi = 191) => b(i) >= lo && b(i) <= hi;
|
|
270
|
+
let n = 0;
|
|
271
|
+
for (let i = from;i < to; ) {
|
|
272
|
+
const c = b(i);
|
|
273
|
+
if (c < 128)
|
|
274
|
+
i += 1;
|
|
275
|
+
else if (c >= 194 && c <= 223 && cont(i + 1))
|
|
276
|
+
i += 2;
|
|
277
|
+
else if (c >= 224 && c <= 239 && cont(i + 1, c === 224 ? 160 : 128, c === 237 ? 159 : 191) && cont(i + 2))
|
|
278
|
+
i += 3;
|
|
279
|
+
else if (c >= 240 && c <= 244 && cont(i + 1, c === 240 ? 144 : 128, c === 244 ? 143 : 191) && cont(i + 2) && cont(i + 3)) {
|
|
280
|
+
i += 4;
|
|
281
|
+
n += 1;
|
|
282
|
+
} else
|
|
283
|
+
i += 1;
|
|
284
|
+
n += 1;
|
|
285
|
+
}
|
|
286
|
+
return n;
|
|
287
|
+
}
|
|
288
|
+
function insertionPoint(code) {
|
|
289
|
+
const start = code.startsWith(BOM) ? BOM.length : 0;
|
|
290
|
+
let at = start;
|
|
291
|
+
if (code.startsWith("#!", at)) {
|
|
292
|
+
const nl = code.indexOf(`
|
|
293
|
+
`, at);
|
|
294
|
+
at = nl < 0 ? code.length : nl + 1;
|
|
295
|
+
}
|
|
296
|
+
for (let m = DIRECTIVE.exec(code.slice(at));m && m[0].length > 0; m = DIRECTIVE.exec(code.slice(at)))
|
|
297
|
+
at += m[0].length;
|
|
298
|
+
let line = 0;
|
|
299
|
+
for (let i = code.indexOf(`
|
|
300
|
+
`);i >= 0 && i < at; i = code.indexOf(`
|
|
301
|
+
`, i + 1))
|
|
302
|
+
line++;
|
|
303
|
+
let lineStart = at === 0 ? 0 : code.lastIndexOf(`
|
|
304
|
+
`, at - 1) + 1;
|
|
305
|
+
if (lineStart === 0)
|
|
306
|
+
lineStart = start;
|
|
307
|
+
return { at, line, column: utf16Units(code, lineStart, at) };
|
|
308
|
+
}
|
|
309
|
+
function injectDebugId(jsBytes, mapBytes) {
|
|
310
|
+
let map;
|
|
311
|
+
try {
|
|
312
|
+
map = JSON.parse(mapBytes.toString("utf8"));
|
|
313
|
+
} catch {
|
|
314
|
+
throw new InjectError("isn't a JSON source map");
|
|
315
|
+
}
|
|
316
|
+
if (typeof map !== "object" || map === null || Array.isArray(map))
|
|
317
|
+
throw new InjectError("isn't a JSON source map");
|
|
318
|
+
const m = map;
|
|
319
|
+
if ("sections" in m)
|
|
320
|
+
throw new InjectError("is an index map (with sections), which inject doesn't support: build with a regular source map");
|
|
321
|
+
if (m.version !== 3 || typeof m.mappings !== "string")
|
|
322
|
+
throw new InjectError("isn't a version 3 source map with mappings");
|
|
323
|
+
if ("debugId" in m && !(typeof m.debugId === "string" && UUID.test(m.debugId.toLowerCase())))
|
|
324
|
+
throw new InjectError("has a debugId that isn't a UUID");
|
|
325
|
+
const js = jsBytes.toString("latin1");
|
|
326
|
+
const fromSnippet = SNIPPET_ID.exec(js)?.[1]?.toLowerCase();
|
|
327
|
+
const fromComment = [...js.matchAll(COMMENT_ID)].at(-1)?.[1]?.toLowerCase();
|
|
328
|
+
const fromMap = typeof m.debugId === "string" ? m.debugId.toLowerCase() : undefined;
|
|
329
|
+
for (const x of [fromSnippet, fromComment])
|
|
330
|
+
if (x !== undefined && !UUID.test(x))
|
|
331
|
+
throw new InjectError(`has a debug ID that isn't a UUID (${x})`);
|
|
332
|
+
const ids = [...new Set([fromSnippet, fromComment, fromMap].filter((x) => x !== undefined))];
|
|
333
|
+
if (ids.length > 1)
|
|
334
|
+
throw new InjectError(`has two debug IDs (${ids[0]} and ${ids[1]}): rebuild it, then inject`);
|
|
335
|
+
if (fromMap && !fromSnippet && !fromComment)
|
|
336
|
+
throw new InjectError("has a source map with a debug ID but a JS file without one (an inject that didn't finish?): rebuild it, then inject");
|
|
337
|
+
if (fromSnippet && fromComment && fromMap)
|
|
338
|
+
return { code: Buffer.from(jsBytes), map: Buffer.from(mapBytes), debugId: fromSnippet, already: true };
|
|
339
|
+
const id = ids[0] ?? debugIdFor(jsBytes, mapBytes);
|
|
340
|
+
let code = js;
|
|
341
|
+
let mappings = m.mappings;
|
|
342
|
+
if (!fromSnippet) {
|
|
343
|
+
const { at, line, column } = insertionPoint(code);
|
|
344
|
+
const s = snippet(id);
|
|
345
|
+
if (at === code.length && !code.includes(`
|
|
346
|
+
`) && code.slice(code.startsWith(BOM) ? BOM.length : 0).startsWith("#!")) {
|
|
347
|
+
code += `
|
|
348
|
+
` + s;
|
|
349
|
+
} else if (code.startsWith("//", at)) {
|
|
350
|
+
code = code.slice(0, at) + s + `
|
|
351
|
+
` + code.slice(at);
|
|
352
|
+
mappings = splitLine(mappings, line, column);
|
|
353
|
+
} else {
|
|
354
|
+
code = code.slice(0, at) + s + code.slice(at);
|
|
355
|
+
mappings = shiftColumns(mappings, line, column, s.length);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (!fromComment) {
|
|
359
|
+
const u = MAP_URL_LINE.exec(code);
|
|
360
|
+
const comment = `//# debugId=${id}
|
|
361
|
+
`;
|
|
362
|
+
if (u) {
|
|
363
|
+
const i = u.index + u[1].length;
|
|
364
|
+
code = code.slice(0, i) + comment + code.slice(i);
|
|
365
|
+
} else {
|
|
366
|
+
code += (code.endsWith(`
|
|
367
|
+
`) ? "" : `
|
|
368
|
+
`) + comment;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return { code: Buffer.from(code, "latin1"), map: Buffer.from(JSON.stringify({ ...m, debugId: id, mappings })), debugId: id, already: false };
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// packages/rum-build/src/upload.ts
|
|
375
|
+
import { createHash as createHash2, randomUUID } from "node:crypto";
|
|
376
|
+
var CHUNK_BYTES = 8 * 1024 * 1024;
|
|
377
|
+
var MISSING_BATCH = 1000;
|
|
378
|
+
var COMMIT_BATCH = 1000;
|
|
379
|
+
var CONCURRENCY = 4;
|
|
380
|
+
var ATTEMPTS = 4;
|
|
381
|
+
|
|
382
|
+
class UploadError extends Error {
|
|
383
|
+
status;
|
|
384
|
+
code;
|
|
385
|
+
body;
|
|
386
|
+
name = "UploadError";
|
|
387
|
+
constructor(message, status, code, body) {
|
|
388
|
+
super(message);
|
|
389
|
+
this.status = status;
|
|
390
|
+
this.code = code;
|
|
391
|
+
this.body = body;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
var sha256 = (b) => createHash2("sha256").update(b).digest("hex");
|
|
395
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
396
|
+
async function upload(t, files) {
|
|
397
|
+
const f = t.fetch ?? fetch;
|
|
398
|
+
const base = `${t.apiUrl.replace(/\/+$/, "")}/v1/organizations/${t.organizationId}/projects/${t.projectId}/obs/source-maps`;
|
|
399
|
+
const chunkBytes = new Map;
|
|
400
|
+
const entries = files.map((file) => {
|
|
401
|
+
const chunks = [];
|
|
402
|
+
for (let o = 0;o < file.bytes.byteLength || o === 0; o += CHUNK_BYTES) {
|
|
403
|
+
const part = file.bytes.subarray(o, o + CHUNK_BYTES);
|
|
404
|
+
const h = sha256(part);
|
|
405
|
+
chunks.push(h);
|
|
406
|
+
chunkBytes.set(h, part);
|
|
407
|
+
}
|
|
408
|
+
return { debugId: file.debugId, path: file.path, kind: file.kind, size: file.bytes.byteLength, chunks };
|
|
409
|
+
});
|
|
410
|
+
async function call(path, init, attempt = 0) {
|
|
411
|
+
let res;
|
|
412
|
+
try {
|
|
413
|
+
res = await f(base + path, { ...init, headers: { Authorization: t.authorization, ...init.headers } });
|
|
414
|
+
} catch (e) {
|
|
415
|
+
if (attempt + 1 >= ATTEMPTS)
|
|
416
|
+
throw e;
|
|
417
|
+
await sleep(1000 * 2 ** attempt);
|
|
418
|
+
return call(path, init, attempt + 1);
|
|
419
|
+
}
|
|
420
|
+
if (res.ok)
|
|
421
|
+
return res.status === 204 ? undefined : res.json();
|
|
422
|
+
const ra = Number(res.headers.get("Retry-After"));
|
|
423
|
+
if ((res.status === 429 || res.status >= 500) && attempt + 1 < ATTEMPTS) {
|
|
424
|
+
await res.body?.cancel().catch(() => {
|
|
425
|
+
return;
|
|
426
|
+
});
|
|
427
|
+
await sleep(Number.isFinite(ra) && ra > 0 ? Math.min(ra, 60) * 1000 : 1000 * 2 ** attempt);
|
|
428
|
+
return call(path, init, attempt + 1);
|
|
429
|
+
}
|
|
430
|
+
const body = (await res.json().catch(() => ({}))).error ?? {};
|
|
431
|
+
throw new UploadError(explain(res.status, body, res.statusText), res.status, body.code ?? "", body);
|
|
432
|
+
}
|
|
433
|
+
const json = (body, extra = {}) => ({ method: "POST", body: JSON.stringify(body), headers: { "Content-Type": "application/json", ...extra } });
|
|
434
|
+
async function putChunks(hashes) {
|
|
435
|
+
const queue = [...new Set(hashes)].filter((h) => chunkBytes.has(h));
|
|
436
|
+
const n = queue.length;
|
|
437
|
+
await Promise.all(Array.from({ length: CONCURRENCY }, async () => {
|
|
438
|
+
for (let h = queue.shift();h; h = queue.shift()) {
|
|
439
|
+
await call("/chunks", { method: "POST", body: chunkBytes.get(h), headers: { "Content-Type": "application/octet-stream", "x-ezgh-sha256": h, "Idempotency-Key": randomUUID() } });
|
|
440
|
+
}
|
|
441
|
+
}));
|
|
442
|
+
return n;
|
|
443
|
+
}
|
|
444
|
+
let uploaded = 0;
|
|
445
|
+
const all = [...chunkBytes.keys()];
|
|
446
|
+
for (let i = 0;i < all.length; i += MISSING_BATCH) {
|
|
447
|
+
const { missing } = await call("/chunks/missing", json({ hashes: all.slice(i, i + MISSING_BATCH) }));
|
|
448
|
+
uploaded += await putChunks(missing);
|
|
449
|
+
}
|
|
450
|
+
const sorted = [...entries].sort((a, b) => a.debugId.localeCompare(b.debugId) || a.kind.localeCompare(b.kind));
|
|
451
|
+
for (let i = 0;i < sorted.length; ) {
|
|
452
|
+
let j = Math.min(i + COMMIT_BATCH, sorted.length);
|
|
453
|
+
while (j < sorted.length && j > i + 1 && sorted[j].debugId === sorted[j - 1].debugId)
|
|
454
|
+
j--;
|
|
455
|
+
const body = { application: t.application, release: t.release, files: sorted.slice(i, j) };
|
|
456
|
+
try {
|
|
457
|
+
await call("", json(body, { "Idempotency-Key": randomUUID() }));
|
|
458
|
+
} catch (e) {
|
|
459
|
+
const missing = e instanceof UploadError && e.status === 409 && e.code === "chunks_missing" ? e.body.details?.missing : undefined;
|
|
460
|
+
if (!missing)
|
|
461
|
+
throw e;
|
|
462
|
+
uploaded += await putChunks(missing);
|
|
463
|
+
await call("", json(body, { "Idempotency-Key": randomUUID() }));
|
|
464
|
+
}
|
|
465
|
+
t.log?.(`ezgh-rum: committed ${j - i} files for ${t.application}@${t.release}`);
|
|
466
|
+
i = j;
|
|
467
|
+
}
|
|
468
|
+
return { files: entries.length, chunksUploaded: uploaded };
|
|
469
|
+
}
|
|
470
|
+
function explain(status, e, statusText) {
|
|
471
|
+
const code = e.code ?? "";
|
|
472
|
+
const message = e.message ?? statusText;
|
|
473
|
+
if (status === 401 || status === 403)
|
|
474
|
+
return "the key can't upload source maps: give its owner the ObsSourceMapUploadAccess policy";
|
|
475
|
+
if (code === "debug_id_conflict") {
|
|
476
|
+
const ids = e.details?.debugIds?.length ? e.details.debugIds.join(", ") : message;
|
|
477
|
+
return `debug ID ${ids} is already registered with different content: rebuild, then upload`;
|
|
478
|
+
}
|
|
479
|
+
if (code === "storage_limit_exceeded")
|
|
480
|
+
return "the project's 10 GiB source-map storage is full: delete old releases (ezgh obs sourcemaps delete)";
|
|
481
|
+
return `obs-api answered ${status} ${code}: ${message}`;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// packages/rum-build/src/process.ts
|
|
485
|
+
async function processOutput(dir, o = {}) {
|
|
486
|
+
const log = o.log ?? ((m) => console.log(m));
|
|
487
|
+
try {
|
|
488
|
+
return await run(dir, o, log);
|
|
489
|
+
} catch (e) {
|
|
490
|
+
if (o.failOnError ?? true)
|
|
491
|
+
throw e;
|
|
492
|
+
log(`ezgh-rum: ${e instanceof Error ? e.message : String(e)}`);
|
|
493
|
+
return { injected: 0, uploaded: 0 };
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
async function run(dir, o, log) {
|
|
497
|
+
const env = process.env;
|
|
498
|
+
const pairs = await findPairs(dir, o.include, log);
|
|
499
|
+
const fresh = [], all = [];
|
|
500
|
+
const prefix = o.pathPrefix ?? "";
|
|
501
|
+
let injected = 0;
|
|
502
|
+
for (const p of pairs) {
|
|
503
|
+
const jsPath = join2(dir, p.js), mapPath = join2(dir, p.map);
|
|
504
|
+
const [js, map] = await Promise.all([readFile2(jsPath), readFile2(mapPath)]);
|
|
505
|
+
let out;
|
|
506
|
+
try {
|
|
507
|
+
out = injectDebugId(js, map);
|
|
508
|
+
} catch (e) {
|
|
509
|
+
if (e instanceof InjectError)
|
|
510
|
+
throw new Error(`ezgh-rum: ${p.js} ${e.message}`, { cause: e });
|
|
511
|
+
throw e;
|
|
512
|
+
}
|
|
513
|
+
if (!out.already) {
|
|
514
|
+
if (!out.code.equals(js))
|
|
515
|
+
await writeFile(jsPath, out.code);
|
|
516
|
+
if (!out.map.equals(map))
|
|
517
|
+
await writeFile(mapPath, out.map);
|
|
518
|
+
injected++;
|
|
519
|
+
}
|
|
520
|
+
const files = [
|
|
521
|
+
{ debugId: out.debugId, path: prefix + p.js, kind: "js", bytes: out.code },
|
|
522
|
+
{ debugId: out.debugId, path: prefix + p.map, kind: "map", bytes: out.map }
|
|
523
|
+
];
|
|
524
|
+
all.push(...files);
|
|
525
|
+
if (!out.already)
|
|
526
|
+
fresh.push(...files);
|
|
527
|
+
}
|
|
528
|
+
const set = fresh.length > 0 ? fresh : all;
|
|
529
|
+
const deleteMaps = (files) => Promise.all(files.filter((f) => f.kind === "map").map((f) => unlink(join2(dir, f.path.slice(prefix.length))).catch(() => {
|
|
530
|
+
return;
|
|
531
|
+
})));
|
|
532
|
+
if (o.upload === false || set.length === 0) {
|
|
533
|
+
if (injected > 0)
|
|
534
|
+
log(`ezgh-rum: debug IDs injected into ${injected} files`);
|
|
535
|
+
if (o.deleteMapsAlways)
|
|
536
|
+
await deleteMaps(all);
|
|
537
|
+
return { injected, uploaded: 0 };
|
|
538
|
+
}
|
|
539
|
+
const application = o.application ?? env.EZGH_RUM_APPLICATION;
|
|
540
|
+
const release = o.release ?? env.EZGH_RUM_RELEASE;
|
|
541
|
+
const organizationId = o.organizationId ?? env.EZGH_ORG;
|
|
542
|
+
const projectId = o.projectId ?? env.EZGH_PROJECT;
|
|
543
|
+
const domain = o.domain ?? env.EZGH_DOMAIN ?? "ezghcloud.com";
|
|
544
|
+
const authorization = organizationId ? await resolveAuthorization({ apiKey: o.apiKey, oidc: o.oidc, organizationId, domain, fetch: o.fetch }, env) : undefined;
|
|
545
|
+
const unset = [
|
|
546
|
+
!authorization && "EZGH_API_KEY (or oidc)",
|
|
547
|
+
!organizationId && "organizationId (EZGH_ORG)",
|
|
548
|
+
!projectId && "projectId (EZGH_PROJECT)",
|
|
549
|
+
!application && "application",
|
|
550
|
+
!release && "release"
|
|
551
|
+
].filter(Boolean);
|
|
552
|
+
if (unset.length > 0) {
|
|
553
|
+
log(`ezgh-rum: debug IDs injected into ${injected} files; not uploading: set ${unset.join(", ")}`);
|
|
554
|
+
if (o.deleteMapsAlways)
|
|
555
|
+
await deleteMaps(all);
|
|
556
|
+
return { injected, uploaded: 0 };
|
|
557
|
+
}
|
|
558
|
+
const r = await upload({
|
|
559
|
+
apiUrl: `https://obs.${domain}`,
|
|
560
|
+
organizationId,
|
|
561
|
+
projectId,
|
|
562
|
+
application,
|
|
563
|
+
release,
|
|
564
|
+
authorization,
|
|
565
|
+
fetch: o.fetch,
|
|
566
|
+
log
|
|
567
|
+
}, set);
|
|
568
|
+
if (o.deleteMapsAlways)
|
|
569
|
+
await deleteMaps(all);
|
|
570
|
+
else if (o.deleteMapsAfterUpload)
|
|
571
|
+
await deleteMaps(set);
|
|
572
|
+
return { injected, uploaded: r.files };
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// packages/rum-build/src/index.ts
|
|
576
|
+
function browserBuild(c, needDevtool) {
|
|
577
|
+
if (c.watchMode || needDevtool && !c.options.devtool)
|
|
578
|
+
return false;
|
|
579
|
+
const t = c.options.target;
|
|
580
|
+
const targets = (Array.isArray(t) ? t : [t]).filter((x) => typeof x === "string");
|
|
581
|
+
return !targets.some((x) => /^(?:async-)?node|^electron-(?:main|preload)/.test(x));
|
|
582
|
+
}
|
|
583
|
+
var ezghRumBuild = createUnplugin((o = {}) => {
|
|
584
|
+
let viteOut, viteSsr = false;
|
|
585
|
+
return {
|
|
586
|
+
name: "ezgh-rum-build",
|
|
587
|
+
vite: {
|
|
588
|
+
apply: "build",
|
|
589
|
+
configResolved(c) {
|
|
590
|
+
viteOut = resolve(c.root, c.build.outDir);
|
|
591
|
+
viteSsr = Boolean(c.build.ssr);
|
|
592
|
+
},
|
|
593
|
+
async writeBundle(out) {
|
|
594
|
+
const env = this.environment;
|
|
595
|
+
if (viteSsr || env?.config?.consumer !== undefined && env.config.consumer !== "client")
|
|
596
|
+
return;
|
|
597
|
+
await processOutput(out.dir ?? viteOut, o);
|
|
598
|
+
}
|
|
599
|
+
},
|
|
600
|
+
rollup: {
|
|
601
|
+
async writeBundle(out) {
|
|
602
|
+
await processOutput(out.dir ?? dirname(out.file), o);
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
webpack(compiler) {
|
|
606
|
+
const c = compiler;
|
|
607
|
+
c.hooks.afterEmit.tapPromise("ezgh-rum-build", async () => {
|
|
608
|
+
if (!browserBuild(c, true))
|
|
609
|
+
return;
|
|
610
|
+
await processOutput(c.options.output.path, o);
|
|
611
|
+
});
|
|
612
|
+
},
|
|
613
|
+
rspack(compiler) {
|
|
614
|
+
const c = compiler;
|
|
615
|
+
c.hooks.afterEmit.tapPromise("ezgh-rum-build", async () => {
|
|
616
|
+
if (!browserBuild(c, true))
|
|
617
|
+
return;
|
|
618
|
+
await processOutput(c.options.output.path, o);
|
|
619
|
+
});
|
|
620
|
+
},
|
|
621
|
+
esbuild: {
|
|
622
|
+
setup(build) {
|
|
623
|
+
build.onEnd(async (r) => {
|
|
624
|
+
const io = build.initialOptions;
|
|
625
|
+
if (r.errors.length || io.write === false)
|
|
626
|
+
return;
|
|
627
|
+
await processOutput(io.outdir ?? dirname(io.outfile), o);
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
});
|
|
633
|
+
export {
|
|
634
|
+
CHUNK_BYTES,
|
|
635
|
+
InjectError,
|
|
636
|
+
UploadError,
|
|
637
|
+
debugIdFor,
|
|
638
|
+
ezghRumBuild,
|
|
639
|
+
injectDebugId,
|
|
640
|
+
processOutput,
|
|
641
|
+
resolveAuthorization,
|
|
642
|
+
shiftColumns,
|
|
643
|
+
snippet,
|
|
644
|
+
upload
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
//# debugId=61B216F94AC531CE64756E2164756E21
|
|
648
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../src/process.ts", "../src/auth.ts", "../src/errors.ts", "../src/files.ts", "../src/inject.ts", "../src/vlq.ts", "../src/upload.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"// @ezghcloud/rum-build: one unplugin whose hooks all run processOutput after the bundler wrote its\n// files, so the same on-disk algorithm serves Vite, Rollup, webpack, Rspack, esbuild and Next.js.\nimport { dirname, resolve } from \"node:path\"\nimport { createUnplugin, type UnpluginInstance } from \"unplugin\"\nimport { processOutput, type EzghRumBuildOptions } from \"./process.ts\"\n\ninterface CompilerLike {\n hooks: { afterEmit: { tapPromise(name: string, fn: () => Promise<void>): void } }\n options: { output: { path?: string }, target?: unknown, devtool?: unknown }\n watchMode?: boolean\n}\n\n// Browser output only, written to disk by a production build: server targets, dev servers and\n// watch mode (often an in-memory file system) are left alone.\nfunction browserBuild(c: CompilerLike, needDevtool: boolean): boolean {\n if (c.watchMode || (needDevtool && !c.options.devtool)) return false\n const t = c.options.target\n const targets = (Array.isArray(t) ? t : [t]).filter((x): x is string => typeof x === \"string\")\n return !targets.some(x => /^(?:async-)?node|^electron-(?:main|preload)/.test(x))\n}\n\nexport const ezghRumBuild: UnpluginInstance<EzghRumBuildOptions | undefined> = createUnplugin((o: EzghRumBuildOptions | undefined = {}) => {\n let viteOut: string | undefined, viteSsr = false\n return {\n name: \"ezgh-rum-build\",\n vite: {\n apply: \"build\",\n configResolved(c) {\n viteOut = resolve(c.root, c.build.outDir)\n viteSsr = Boolean(c.build.ssr)\n },\n async writeBundle(out) {\n const env = (this as { environment?: { config?: { consumer?: string } } }).environment\n if (viteSsr || (env?.config?.consumer !== undefined && env.config.consumer !== \"client\")) return\n await processOutput(out.dir ?? viteOut!, o)\n },\n },\n rollup: {\n async writeBundle(out) {\n await processOutput(out.dir ?? dirname(out.file!), o)\n },\n },\n webpack(compiler) {\n const c = compiler as unknown as CompilerLike\n c.hooks.afterEmit.tapPromise(\"ezgh-rum-build\", async () => {\n if (!browserBuild(c, true)) return\n await processOutput(c.options.output.path!, o)\n })\n },\n rspack(compiler) {\n // Typed structurally: @rspack/core is the customer's, not a dependency of this package.\n const c = compiler as unknown as CompilerLike\n c.hooks.afterEmit.tapPromise(\"ezgh-rum-build\", async () => {\n if (!browserBuild(c, true)) return\n await processOutput(c.options.output.path!, o)\n })\n },\n esbuild: {\n setup(build) {\n build.onEnd(async (r) => {\n const io = build.initialOptions\n if (r.errors.length || io.write === false) return\n await processOutput(io.outdir ?? dirname(io.outfile!), o)\n })\n },\n },\n }\n})\nexport { processOutput, type EzghRumBuildOptions } from \"./process.ts\"\nexport { injectDebugId, debugIdFor, snippet, shiftColumns, InjectError, type Injected } from \"./inject.ts\"\nexport { upload, UploadError, CHUNK_BYTES, type UploadFile, type UploadTarget } from \"./upload.ts\"\nexport { resolveAuthorization, type OidcOptions } from \"./auth.ts\"\n",
|
|
6
|
+
"// What every bundler hook runs once the bundler wrote its files: inject debug IDs into the output\n// on disk, then upload the injected pairs through obs-api.\nimport { readFile, unlink, writeFile } from \"node:fs/promises\"\nimport { join } from \"node:path\"\nimport { resolveAuthorization, type OidcOptions } from \"./auth.ts\"\nimport { InjectError } from \"./errors.ts\"\nimport { findPairs } from \"./files.ts\"\nimport { injectDebugId } from \"./inject.ts\"\nimport { upload, type UploadFile } from \"./upload.ts\"\n\nexport interface EzghRumBuildOptions {\n /** Default env EZGH_RUM_APPLICATION; required to upload. */\n application?: string\n /** Default env EZGH_RUM_RELEASE; required to upload. */\n release?: string\n /** The organization's UUID; default env EZGH_ORG. */\n organizationId?: string\n /** The project's UUID; default env EZGH_PROJECT. */\n projectId?: string\n /** Default env EZGH_API_KEY (setup-ezgh sets it from OIDC). */\n apiKey?: string\n /** GitHub Actions OIDC → a short-lived bot key, when there's no API key. */\n oidc?: OidcOptions\n /** Default env EZGH_DOMAIN, else \"ezghcloud.com\"; uploads go to https://obs.<domain>. */\n domain?: string\n /** Default true; false only injects. */\n upload?: boolean\n /** Default true: an error fails the build. False logs it instead. */\n failOnError?: boolean\n /** Default false (withEzghRum: true): delete the uploaded .map files from the output. */\n deleteMapsAfterUpload?: boolean\n /** Default: .js, .mjs and .cjs files outside node_modules. */\n include?: (relPath: string) => boolean\n /** Prefixed to committed paths (withEzghRum: \"_next/static/\"). */\n pathPrefix?: string\n /**\n * @internal withEzghRum: delete every .map file of the processed pairs, uploaded or not (it turned\n * productionBrowserSourceMaps on, so maps must never be left to be served).\n */\n deleteMapsAlways?: boolean\n /** @internal For tests: the fetch used for obs-api and org-api. */\n fetch?: typeof fetch\n /** @internal For tests: where log lines go (default console.log). */\n log?: (m: string) => void\n}\n\nexport async function processOutput(dir: string, o: EzghRumBuildOptions = {}): Promise<{ injected: number, uploaded: number }> {\n const log = o.log ?? ((m: string) => console.log(m))\n try {\n return await run(dir, o, log)\n }\n catch (e) {\n if (o.failOnError ?? true) throw e\n log(`ezgh-rum: ${e instanceof Error ? e.message : String(e)}`)\n return { injected: 0, uploaded: 0 }\n }\n}\n\nasync function run(dir: string, o: EzghRumBuildOptions, log: (m: string) => void): Promise<{ injected: number, uploaded: number }> {\n const env = process.env\n const pairs = await findPairs(dir, o.include, log)\n const fresh: UploadFile[] = [], all: UploadFile[] = []\n const prefix = o.pathPrefix ?? \"\"\n let injected = 0\n for (const p of pairs) {\n const jsPath = join(dir, p.js), mapPath = join(dir, p.map)\n const [js, map] = await Promise.all([readFile(jsPath), readFile(mapPath)])\n let out\n try {\n out = injectDebugId(js, map)\n }\n catch (e) {\n if (e instanceof InjectError) throw new Error(`ezgh-rum: ${p.js} ${e.message}`, { cause: e })\n throw e\n }\n if (!out.already) {\n if (!out.code.equals(js)) await writeFile(jsPath, out.code)\n if (!out.map.equals(map)) await writeFile(mapPath, out.map)\n injected++\n }\n const files: UploadFile[] = [\n { debugId: out.debugId, path: prefix + p.js, kind: \"js\", bytes: out.code },\n { debugId: out.debugId, path: prefix + p.map, kind: \"map\", bytes: out.map },\n ]\n all.push(...files)\n if (!out.already) fresh.push(...files)\n }\n // The pairs injected in this run, or, when none were (a CLI-injected build), every pair with a\n // debug ID: leftovers of an older build in a non-emptied outDir aren't committed in this release.\n const set = fresh.length > 0 ? fresh : all\n const deleteMaps = (files: readonly UploadFile[]) =>\n Promise.all(files.filter(f => f.kind === \"map\").map(f => unlink(join(dir, f.path.slice(prefix.length))).catch(() => undefined)))\n if (o.upload === false || set.length === 0) {\n if (injected > 0) log(`ezgh-rum: debug IDs injected into ${injected} files`)\n if (o.deleteMapsAlways) await deleteMaps(all)\n return { injected, uploaded: 0 }\n }\n const application = o.application ?? env.EZGH_RUM_APPLICATION\n const release = o.release ?? env.EZGH_RUM_RELEASE\n const organizationId = o.organizationId ?? env.EZGH_ORG\n const projectId = o.projectId ?? env.EZGH_PROJECT\n const domain = o.domain ?? env.EZGH_DOMAIN ?? \"ezghcloud.com\"\n const authorization = organizationId\n ? await resolveAuthorization({ apiKey: o.apiKey, oidc: o.oidc, organizationId, domain, fetch: o.fetch }, env)\n : undefined\n const unset = [\n !authorization && \"EZGH_API_KEY (or oidc)\", !organizationId && \"organizationId (EZGH_ORG)\",\n !projectId && \"projectId (EZGH_PROJECT)\", !application && \"application\", !release && \"release\",\n ].filter(Boolean)\n if (unset.length > 0) {\n log(`ezgh-rum: debug IDs injected into ${injected} files; not uploading: set ${unset.join(\", \")}`)\n if (o.deleteMapsAlways) await deleteMaps(all)\n return { injected, uploaded: 0 }\n }\n const r = await upload({\n apiUrl: `https://obs.${domain}`, organizationId: organizationId!, projectId: projectId!, application: application!,\n release: release!, authorization: authorization!, fetch: o.fetch, log,\n }, set)\n if (o.deleteMapsAlways) await deleteMaps(all)\n else if (o.deleteMapsAfterUpload) await deleteMaps(set)\n return { injected, uploaded: r.files }\n}\n",
|
|
7
|
+
"// The upload credential: an API key (EZGH_API_KEY, which setup-ezgh sets in GitHub Actions), or a\n// GitHub Actions OIDC token exchanged at org-api for a short-lived bot key. Keys are never logged.\nexport interface OidcOptions { bot: string, audience?: string }\n\nexport async function resolveAuthorization(\n o: { apiKey?: string, oidc?: OidcOptions, organizationId: string, domain: string, fetch?: typeof fetch },\n env: Readonly<Record<string, string | undefined>>,\n): Promise<string | undefined> {\n const key = o.apiKey || env.EZGH_API_KEY\n if (key) return `Bearer ${key}`\n const url = env.ACTIONS_ID_TOKEN_REQUEST_URL, requestToken = env.ACTIONS_ID_TOKEN_REQUEST_TOKEN\n if (!o.oidc || !url || !requestToken) return undefined\n const f = o.fetch ?? fetch\n const audience = o.oidc.audience ?? o.domain\n const idRes = await f(`${url}${url.includes(\"?\") ? \"&\" : \"?\"}audience=${encodeURIComponent(audience)}`, {\n headers: { Authorization: `Bearer ${requestToken}` },\n })\n if (!idRes.ok) throw new Error(`ezgh-rum: GitHub Actions didn't issue an OIDC token (${idRes.status}): give the job \"permissions: id-token: write\"`)\n const { value } = await idRes.json() as { value?: string }\n if (!value) throw new Error(\"ezgh-rum: GitHub Actions answered without an OIDC token\")\n const exchange = `https://orgs.${o.domain}/v1/organizations/${encodeURIComponent(o.organizationId)}/bots/${encodeURIComponent(o.oidc.bot)}/oidc-api-keys`\n for (let attempt = 0; ; attempt++) {\n // No Authorization header: the OIDC token is the credential.\n const res = await f(exchange, {\n method: \"POST\", headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ token: value, name: \"ezgh-rum-build\", expiresInSeconds: 900 }),\n })\n if (res.ok) {\n const { token } = await res.json() as { token?: string }\n if (!token) throw new Error(\"ezgh-rum: org-api answered the OIDC exchange without a key\")\n return `Bearer ${token}`\n }\n if ((res.status === 429 || res.status === 503) && attempt < 3) {\n const ra = Number(res.headers.get(\"Retry-After\"))\n await new Promise(r => setTimeout(r, Number.isFinite(ra) && ra > 0 ? Math.min(ra, 60) * 1000 : 1000 * 2 ** attempt))\n continue\n }\n const body = await res.json().catch(() => ({})) as { error?: { code?: string, message?: string } }\n throw new Error(`ezgh-rum: the OIDC exchange for bot ${o.oidc.bot} failed (${res.status} ${body.error?.code ?? \"\"}): ${body.error?.message ?? res.statusText}`)\n }\n}\n",
|
|
8
|
+
"/** A JS file or source map that injection refuses; the message reads after the file's path. */\nexport class InjectError extends Error {\n override name = \"InjectError\"\n}\n",
|
|
9
|
+
"// Finds the JS files of a build's output and their source maps, on disk, after the bundler wrote\n// them: one algorithm for every bundler, and the same as ezgh-cli's sourcemaps.Find:\n// - walk the directory without following symlinks, skipping node_modules;\n// - a JS file's map is the file its trailing //# sourceMappingURL= comment names (relative,\n// inside the directory, a regular file, not reached through a symlink), else <file>.map when\n// there's no comment; a data: URL, an absolute or outside URL, or no map skips the file;\n// - a map named by two JS files pairs neither.\nimport { existsSync } from \"node:fs\"\nimport { lstat, readdir, readFile, realpath } from \"node:fs/promises\"\nimport { join, posix, relative, sep } from \"node:path\"\n\nexport interface Pair { js: string, map: string } // paths relative to the output directory, with \"/\"\ninterface Skipped { path: string, reason: string }\n\nconst isJS = (rel: string) => /\\.(?:m|c)?js$/.test(rel)\nconst MAP_URL = /(?:^|\\n)\\/\\/[#@] sourceMappingURL=([^\\t\\n\\f\\r ]*)[\\t\\n\\f\\r ]*$/\n\nasync function walk(root: string, rel: string, out: string[]): Promise<void> {\n for (const d of await readdir(join(root, rel), { withFileTypes: true })) {\n const r = rel ? `${rel}/${d.name}` : d.name\n if (d.isDirectory()) {\n if (d.name !== \"node_modules\") await walk(root, r, out)\n }\n else if (d.isFile() && isJS(d.name)) out.push(r) // symlinks and other non-regular files are never followed\n }\n}\n\nasync function isRegular(p: string): Promise<boolean> {\n try {\n return (await lstat(p)).isFile()\n }\n catch {\n return false\n }\n}\n\nasync function inside(root: string, p: string): Promise<boolean> {\n try {\n const rel = relative(root, await realpath(p))\n return rel !== \"\" && !rel.startsWith(\"..\") && !rel.split(sep).includes(\"..\") && !/^[a-zA-Z]:/.test(rel) && !rel.startsWith(sep)\n }\n catch {\n return false\n }\n}\n\nasync function mapFor(dir: string, rel: string): Promise<[string, \"\"] | [undefined, string]> {\n const text = await readFile(join(dir, rel), \"latin1\")\n const m = MAP_URL.exec(text)\n if (m) {\n const u = m[1]!\n if (u.toLowerCase().startsWith(\"data:\")) return [undefined, \"its source map is inline (a data: URL): build with external source maps\"]\n if (u === \"\") return [undefined, \"its sourceMappingURL comment is empty\"]\n // Go's url.Parse: a scheme or host means not relative; the path is percent-decoded, without\n // the query and fragment.\n if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(u) || u.startsWith(\"//\")) return [undefined, `its sourceMappingURL ${u} isn't a relative path`]\n let path = u.replace(/[?#].*$/s, \"\")\n try {\n path = decodeURIComponent(path)\n }\n catch {\n return [undefined, `its sourceMappingURL ${u} isn't a relative path`]\n }\n if (path.startsWith(\"/\") || path.includes(\"\\\\\")) return [undefined, `its sourceMappingURL ${u} isn't a relative path`]\n const target = posix.normalize(posix.join(posix.dirname(rel), path))\n if (target === \"..\" || target.startsWith(\"../\")) return [undefined, `its source map ${u} is outside the directory`]\n const abs = join(dir, ...target.split(\"/\"))\n if (!(await isRegular(abs))) return [undefined, `its source map ${target} isn't there`]\n if (!(await inside(dir, abs))) return [undefined, `its source map ${u} is outside the directory (through a symlink)`]\n return [target, \"\"]\n }\n if (await isRegular(join(dir, ...`${rel}.map`.split(\"/\")))) return [`${rel}.map`, \"\"]\n return [undefined, \"no source map\"]\n}\n\nexport async function findPairs(dir: string, include: ((rel: string) => boolean) | undefined, log: (m: string) => void): Promise<Pair[]> {\n if (!existsSync(dir)) return []\n const root = await realpath(dir) // the directory itself may be a symlink\n const files: string[] = []\n await walk(root, \"\", files)\n files.sort()\n let pairs: Pair[] = []\n const skipped: Skipped[] = []\n for (const rel of files) {\n if (include && !include(rel)) continue\n const [map, reason] = await mapFor(root, rel)\n if (map === undefined) skipped.push({ path: rel, reason })\n else pairs.push({ js: rel, map })\n }\n const users = new Map<string, string[]>()\n for (const p of pairs) users.set(p.map, [...(users.get(p.map) ?? []), p.js])\n pairs = pairs.filter((p) => {\n const js = users.get(p.map)!\n if (js.length < 2) return true\n skipped.push({ path: p.js, reason: `its source map ${p.map} is also ${js.filter(x => x !== p.js).join(\", \")}'s: build with one map per file` })\n return false\n })\n const shown = skipped.filter(s => s.reason !== \"no source map\")\n for (const s of shown.slice(0, 20)) log(`ezgh-rum: skipped ${s.path}: ${s.reason}`)\n if (shown.length > 20) log(`ezgh-rum: skipped ${shown.length - 20} more file(s)`)\n const noMap = skipped.length - shown.length\n if (noMap > 0) log(`ezgh-rum: skipped ${noMap} JS file(s) without a source map`)\n return pairs\n}\n",
|
|
10
|
+
"// Debug-ID injection: CLI L2's algorithm (ezgh-cli internal/sourcemaps), ported byte for byte. The\n// CLI owns the algorithm and its vectors (test/vectors/inject, synced by\n// scripts/sync-inject-vectors.sh); this file must reproduce every vector's out.js exactly.\nimport { createHash } from \"node:crypto\"\nimport { InjectError } from \"./errors.ts\"\nimport { vlqDecode, vlqEncode } from \"./vlq.ts\"\n\nexport { InjectError }\nexport interface Injected { code: Buffer, map: Buffer, debugId: string, already: boolean }\n\n/**\n * The registration code inserted into every JS file: one line, no newline. It registers the debug\n * ID under the Error stack of the code that runs it, so the SDK maps the script's URL (the stack's\n * first frame) to its debug ID. It never throws.\n */\nexport function snippet(id: string): string {\n return \";!function(){try{var g=\\\"undefined\\\"!=typeof globalThis?globalThis:\\\"undefined\\\"!=typeof self?self:\"\n + \"\\\"undefined\\\"!=typeof window?window:{},s=(new g.Error).stack;s&&((g._ezghDebugIds=g._ezghDebugIds||{})[s]=\\\"\"\n + id + \"\\\")}catch(e){}}();\"\n}\n\n/**\n * A file pair's debug ID, from its content: SHA-256 of \"ezgh-debug-id\\0\" + js + \"\\0\" + map, the\n * first 16 bytes with the RFC 9562 version (4) and variant bits, as a lowercase UUID.\n */\nexport function debugIdFor(js: Uint8Array, map: Uint8Array): string {\n const h = createHash(\"sha256\").update(\"ezgh-debug-id\\0\").update(js).update(\"\\0\").update(map).digest()\n h[6] = (h[6]! & 0x0f) | 0x40\n h[8] = (h[8]! & 0x3f) | 0x80\n const x = h.subarray(0, 16).toString(\"hex\")\n return `${x.slice(0, 8)}-${x.slice(8, 12)}-${x.slice(12, 16)}-${x.slice(16, 20)}-${x.slice(20)}`\n}\n\n/**\n * Moves every mapping of generated line `line` at column >= `col` right by `delta`. Generated\n * columns are relative within a line, so only the first such segment's first field changes; every\n * other byte of `mappings` stays as it is.\n */\nexport function shiftColumns(mappings: string, line: number, col: number, delta: number): string {\n let start = 0\n for (let k = 0; k < line; k++) {\n const j = mappings.indexOf(\";\", start)\n if (j < 0) return mappings // no mappings on that line or after it\n start = j + 1\n }\n const semi = mappings.indexOf(\";\", start)\n const end = semi < 0 ? mappings.length : semi\n let abs = 0\n for (let seg = start; seg < end;) {\n const comma = mappings.indexOf(\",\", seg)\n const segEnd = comma >= 0 && comma < end ? comma : end\n if (seg === segEnd) { // an empty segment\n seg++\n continue\n }\n const { value, next } = vlqDecode(mappings, seg)\n if (next > segEnd) throw new InjectError(\"has malformed mappings\")\n abs += value\n if (abs >= col) return mappings.slice(0, seg) + vlqEncode(value + delta) + mappings.slice(next)\n seg = segEnd + 1\n }\n return mappings\n}\n\n/**\n * Moves the mappings of generated line `line` at column >= `col` to a new line after it, their\n * columns less `col`. Only the first moved segment's generated column changes (the other fields\n * are relative across lines); a line with nothing at `col` or after gains an empty line.\n */\nexport function splitLine(mappings: string, line: number, col: number): string {\n let start = 0\n for (let k = 0; k < line; k++) {\n const j = mappings.indexOf(\";\", start)\n if (j < 0) return mappings // no mappings on that line or after it\n start = j + 1\n }\n const semi = mappings.indexOf(\";\", start)\n const end = semi < 0 ? mappings.length : semi\n let abs = 0\n for (let seg = start; seg < end;) {\n const comma = mappings.indexOf(\",\", seg)\n const segEnd = comma >= 0 && comma < end ? comma : end\n if (seg === segEnd) {\n seg++\n continue\n }\n const { value, next } = vlqDecode(mappings, seg)\n if (next > segEnd) throw new InjectError(\"has malformed mappings\")\n abs += value\n if (abs >= col) return mappings.slice(0, seg > start ? seg - 1 : seg) + \";\" + vlqEncode(abs - col) + mappings.slice(next)\n seg = segEnd + 1\n }\n return mappings.slice(0, end) + \";\" + mappings.slice(end)\n}\n\n// The JS is matched as a byte string (latin1: one char per byte), as Go's regexp matches the\n// file's bytes, so every byte (a BOM, invalid UTF-8) comes out as it went in. Every pattern is\n// ASCII, and RE2's \\s is [\\t\\n\\f\\r ] and its . excludes only \\n: spelled out so JS matches Go.\nconst UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/\nconst SNIPPET_ID = /\\(g\\._ezghDebugIds=g\\._ezghDebugIds\\|\\|\\{\\}\\)\\[s\\]=\"([0-9a-f-]{36})\"/\n// Go's (?m)^…\\s*$: a line start is the start or after \\n, a line end the end or before \\n.\nconst COMMENT_ID = /(?<![^\\n])\\/\\/# debugId=([0-9a-fA-F-]{36})[\\t\\n\\f\\r ]*(?![^\\n])/g\n// One directive of the prologue (and the whitespace and comments before it). A block comment\n// can't contain */; \"a\".split(…) isn't a directive and doesn't match.\nconst DIRECTIVE = /^(?:[\\t\\n\\f\\r ]|\\/\\*[^*]*\\*+(?:[^/*][^*]*\\*+)*\\/|\\/\\/[^\\n]*\\n)*(?:\"(?:[^\"\\\\\\r\\n]|\\\\[^\\n])*\"|'(?:[^'\\\\\\r\\n]|\\\\[^\\n])*')[ \\t]*(?:;|\\r?\\n|$)/\n// The file's last line, when it's a sourceMappingURL comment (whitespace may follow).\nconst MAP_URL_LINE = /(^|\\n)\\/\\/[#@] sourceMappingURL=[^\\n]*[\\t\\n\\f\\r ]*$/\nconst BOM = \"\\xEF\\xBB\\xBF\"\n\n/** UTF-16 units of the UTF-8 bytes s[from, to) (a latin1 byte string), decoded as Go ranges a string: an invalid byte is one unit. */\nfunction utf16Units(s: string, from: number, to: number): number {\n const b = (i: number) => (i < to ? s.charCodeAt(i) : -1)\n const cont = (i: number, lo = 0x80, hi = 0xbf) => b(i) >= lo && b(i) <= hi\n let n = 0\n for (let i = from; i < to;) {\n const c = b(i)\n if (c < 0x80) i += 1\n else if (c >= 0xc2 && c <= 0xdf && cont(i + 1)) i += 2\n else if (c >= 0xe0 && c <= 0xef && cont(i + 1, c === 0xe0 ? 0xa0 : 0x80, c === 0xed ? 0x9f : 0xbf) && cont(i + 2)) i += 3\n else if (c >= 0xf0 && c <= 0xf4 && cont(i + 1, c === 0xf0 ? 0x90 : 0x80, c === 0xf4 ? 0x8f : 0xbf) && cont(i + 2) && cont(i + 3)) {\n i += 4\n n += 1 // a supplementary character is a surrogate pair\n }\n else i += 1 // invalid: U+FFFD, one unit\n n += 1\n }\n return n\n}\n\n/**\n * Where the snippet goes: after a byte-order mark, a #! line and the whole directive prologue, so\n * \"use strict\" stays a directive. The byte offset, and the generated line and column (UTF-16\n * units, the BOM not counted) that source maps use.\n */\nfunction insertionPoint(code: string): { at: number, line: number, column: number } {\n const start = code.startsWith(BOM) ? BOM.length : 0\n let at = start\n if (code.startsWith(\"#!\", at)) {\n const nl = code.indexOf(\"\\n\", at)\n at = nl < 0 ? code.length : nl + 1\n }\n for (let m = DIRECTIVE.exec(code.slice(at)); m && m[0].length > 0; m = DIRECTIVE.exec(code.slice(at))) at += m[0].length\n let line = 0\n for (let i = code.indexOf(\"\\n\"); i >= 0 && i < at; i = code.indexOf(\"\\n\", i + 1)) line++\n let lineStart = at === 0 ? 0 : code.lastIndexOf(\"\\n\", at - 1) + 1\n if (lineStart === 0) lineStart = start\n return { at, line, column: utf16Units(code, lineStart, at) }\n}\n\n/**\n * Adds the debug ID to a JS file and its source map: the snippet after a BOM, a shebang line and\n * the directive prologue (with the map's columns shifted), a `//# debugId=` comment before a\n * trailing `sourceMappingURL` line (or at the end), and the map's `debugId`. `already` is true,\n * with the input unchanged, when all three are there and agree.\n */\nexport function injectDebugId(jsBytes: Buffer, mapBytes: Buffer): Injected {\n let map: unknown\n try {\n map = JSON.parse(mapBytes.toString(\"utf8\"))\n }\n catch {\n throw new InjectError(\"isn't a JSON source map\")\n }\n if (typeof map !== \"object\" || map === null || Array.isArray(map)) throw new InjectError(\"isn't a JSON source map\")\n const m = map as Record<string, unknown>\n if (\"sections\" in m) throw new InjectError(\"is an index map (with sections), which inject doesn't support: build with a regular source map\")\n if (m.version !== 3 || typeof m.mappings !== \"string\") throw new InjectError(\"isn't a version 3 source map with mappings\")\n if (\"debugId\" in m && !(typeof m.debugId === \"string\" && UUID.test(m.debugId.toLowerCase()))) throw new InjectError(\"has a debugId that isn't a UUID\")\n\n const js = jsBytes.toString(\"latin1\")\n const fromSnippet = SNIPPET_ID.exec(js)?.[1]?.toLowerCase()\n const fromComment = [...js.matchAll(COMMENT_ID)].at(-1)?.[1]?.toLowerCase()\n const fromMap = typeof m.debugId === \"string\" ? m.debugId.toLowerCase() : undefined\n for (const x of [fromSnippet, fromComment]) if (x !== undefined && !UUID.test(x)) throw new InjectError(`has a debug ID that isn't a UUID (${x})`)\n const ids = [...new Set([fromSnippet, fromComment, fromMap].filter((x): x is string => x !== undefined))]\n if (ids.length > 1) throw new InjectError(`has two debug IDs (${ids[0]} and ${ids[1]}): rebuild it, then inject`)\n if (fromMap && !fromSnippet && !fromComment) throw new InjectError(\"has a source map with a debug ID but a JS file without one (an inject that didn't finish?): rebuild it, then inject\")\n if (fromSnippet && fromComment && fromMap) return { code: Buffer.from(jsBytes), map: Buffer.from(mapBytes), debugId: fromSnippet, already: true }\n const id = ids[0] ?? debugIdFor(jsBytes, mapBytes)\n\n let code = js\n let mappings = m.mappings\n if (!fromSnippet) {\n const { at, line, column } = insertionPoint(code)\n const s = snippet(id)\n if (at === code.length && !code.includes(\"\\n\") && code.slice(code.startsWith(BOM) ? BOM.length : 0).startsWith(\"#!\")) {\n // Only a #! line: the snippet goes on a line of its own, after every mapping.\n code += \"\\n\" + s\n }\n else if (code.startsWith(\"//\", at)) {\n // A line comment follows: the snippet ends its line, so the comment still starts a line.\n code = code.slice(0, at) + s + \"\\n\" + code.slice(at)\n mappings = splitLine(mappings, line, column)\n }\n else {\n code = code.slice(0, at) + s + code.slice(at)\n mappings = shiftColumns(mappings, line, column, s.length)\n }\n }\n if (!fromComment) {\n const u = MAP_URL_LINE.exec(code)\n const comment = `//# debugId=${id}\\n`\n if (u) {\n const i = u.index + u[1]!.length // after the newline that ends the previous line\n code = code.slice(0, i) + comment + code.slice(i)\n }\n else {\n code += (code.endsWith(\"\\n\") ? \"\" : \"\\n\") + comment\n }\n }\n return { code: Buffer.from(code, \"latin1\"), map: Buffer.from(JSON.stringify({ ...m, debugId: id, mappings })), debugId: id, already: false }\n}\n",
|
|
11
|
+
"// Base64 VLQ as source maps use it (CLI L2's vlq.go): 5-bit groups, continuation bit 32, the sign\n// in bit 0. Arithmetic rather than bit shifts, so large columns don't overflow 32 bits.\nimport { InjectError } from \"./errors.ts\"\n\nconst ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\"\nconst DIGIT = new Map([...ALPHABET].map((c, i) => [c, i]))\n\nexport function vlqDecode(s: string, at: number): { value: number, next: number } {\n let result = 0\n let shift = 0\n for (let i = at; i < s.length; i++) {\n const d = DIGIT.get(s[i]!)\n if (d === undefined || shift > 30) throw new InjectError(\"has malformed mappings\")\n result += (d & 31) * 2 ** shift\n shift += 5\n if ((d & 32) === 0) {\n const negative = result % 2 === 1\n const magnitude = Math.floor(result / 2)\n return { value: negative ? -magnitude : magnitude, next: i + 1 }\n }\n }\n throw new InjectError(\"has malformed mappings\")\n}\n\nexport function vlqEncode(v: number): string {\n let n = v < 0 ? -v * 2 + 1 : v * 2\n let out = \"\"\n do {\n let digit = n % 32\n n = Math.floor(n / 32)\n if (n > 0) digit += 32\n out += ALPHABET[digit]\n } while (n > 0)\n return out\n}\n",
|
|
12
|
+
"// The chunked, content-addressed source-map upload through obs-api (spec \"Source maps\", plan 25\n// interface corrections 2–4): chunks/missing, then the missing chunks, then commits of at most\n// 1,000 files that never split a debug ID's js and map. obs-api never returns a storage URL, and\n// nothing here builds or logs any URL but obs-api's.\nimport { createHash, randomUUID } from \"node:crypto\"\n\nexport const CHUNK_BYTES = 8 * 1024 * 1024\nexport const MISSING_BATCH = 1000\nexport const COMMIT_BATCH = 1000\nconst CONCURRENCY = 4\nconst ATTEMPTS = 4\n\nexport interface UploadFile { debugId: string, path: string, kind: \"js\" | \"map\", bytes: Uint8Array }\nexport interface UploadTarget {\n apiUrl: string\n organizationId: string\n projectId: string\n application: string\n release: string\n authorization: string\n fetch?: typeof fetch\n log?: (m: string) => void\n}\n// obs-api errors: {\"error\":{\"code\",\"message\",\"details\":{…}}} (chunks_missing: details.missing; debug_id_conflict: details.debugIds).\ninterface ErrorBody { code?: string, message?: string, details?: { missing?: string[], debugIds?: string[] } }\nexport class UploadError extends Error {\n override name = \"UploadError\"\n constructor(message: string, readonly status: number, readonly code: string, readonly body: ErrorBody) {\n super(message)\n }\n}\n\nconst sha256 = (b: Uint8Array): string => createHash(\"sha256\").update(b).digest(\"hex\")\nconst sleep = (ms: number) => new Promise(r => setTimeout(r, ms))\n\nexport async function upload(t: UploadTarget, files: readonly UploadFile[]): Promise<{ files: number, chunksUploaded: number }> {\n const f = t.fetch ?? fetch\n const base = `${t.apiUrl.replace(/\\/+$/, \"\")}/v1/organizations/${t.organizationId}/projects/${t.projectId}/obs/source-maps`\n const chunkBytes = new Map<string, Uint8Array>()\n const entries = files.map((file) => {\n const chunks: string[] = []\n for (let o = 0; o < file.bytes.byteLength || o === 0; o += CHUNK_BYTES) {\n const part = file.bytes.subarray(o, o + CHUNK_BYTES)\n const h = sha256(part)\n chunks.push(h)\n chunkBytes.set(h, part)\n }\n // A file is (size, chunks): no whole-file hash (interface correction 4).\n return { debugId: file.debugId, path: file.path, kind: file.kind, size: file.bytes.byteLength, chunks }\n })\n\n async function call(path: string, init: RequestInit, attempt = 0): Promise<unknown> {\n let res: Response\n try {\n res = await f(base + path, { ...init, headers: { Authorization: t.authorization, ...(init.headers as Record<string, string>) } })\n }\n catch (e) {\n if (attempt + 1 >= ATTEMPTS) throw e\n await sleep(1000 * 2 ** attempt)\n return call(path, init, attempt + 1)\n }\n if (res.ok) return res.status === 204 ? undefined : res.json()\n const ra = Number(res.headers.get(\"Retry-After\"))\n if ((res.status === 429 || res.status >= 500) && attempt + 1 < ATTEMPTS) {\n await res.body?.cancel().catch(() => undefined)\n await sleep(Number.isFinite(ra) && ra > 0 ? Math.min(ra, 60) * 1000 : 1000 * 2 ** attempt)\n return call(path, init, attempt + 1)\n }\n // obs-api errors are { \"error\": { \"code\", \"message\", ...extra fields } }.\n const body = (await res.json().catch(() => ({})) as { error?: ErrorBody }).error ?? {}\n throw new UploadError(explain(res.status, body, res.statusText), res.status, body.code ?? \"\", body)\n }\n const json = (body: unknown, extra: Record<string, string> = {}): RequestInit =>\n ({ method: \"POST\", body: JSON.stringify(body), headers: { \"Content-Type\": \"application/json\", ...extra } })\n\n async function putChunks(hashes: readonly string[]): Promise<number> {\n const queue = [...new Set(hashes)].filter(h => chunkBytes.has(h))\n const n = queue.length\n await Promise.all(Array.from({ length: CONCURRENCY }, async () => {\n for (let h = queue.shift(); h; h = queue.shift()) {\n await call(\"/chunks\", { method: \"POST\", body: chunkBytes.get(h)! as Uint8Array<ArrayBuffer>, headers: { \"Content-Type\": \"application/octet-stream\", \"x-ezgh-sha256\": h, \"Idempotency-Key\": randomUUID() } })\n }\n }))\n return n\n }\n\n let uploaded = 0\n const all = [...chunkBytes.keys()]\n for (let i = 0; i < all.length; i += MISSING_BATCH) {\n const { missing } = await call(\"/chunks/missing\", json({ hashes: all.slice(i, i + MISSING_BATCH) })) as { missing: string[] }\n uploaded += await putChunks(missing)\n }\n // Pairs stay together: sort by debug ID and cut only between IDs.\n const sorted = [...entries].sort((a, b) => a.debugId.localeCompare(b.debugId) || a.kind.localeCompare(b.kind))\n for (let i = 0; i < sorted.length;) {\n let j = Math.min(i + COMMIT_BATCH, sorted.length)\n while (j < sorted.length && j > i + 1 && sorted[j]!.debugId === sorted[j - 1]!.debugId) j--\n const body = { application: t.application, release: t.release, files: sorted.slice(i, j) }\n try {\n await call(\"\", json(body, { \"Idempotency-Key\": randomUUID() }))\n }\n catch (e) {\n const missing = e instanceof UploadError && e.status === 409 && e.code === \"chunks_missing\" ? e.body.details?.missing : undefined\n if (!missing) throw e\n // A chunk went away between chunks/missing and the commit: upload it, then commit once more.\n uploaded += await putChunks(missing)\n await call(\"\", json(body, { \"Idempotency-Key\": randomUUID() }))\n }\n t.log?.(`ezgh-rum: committed ${j - i} files for ${t.application}@${t.release}`)\n i = j\n }\n return { files: entries.length, chunksUploaded: uploaded }\n}\n\nfunction explain(status: number, e: ErrorBody, statusText: string): string {\n const code = e.code ?? \"\"\n const message = e.message ?? statusText\n if (status === 401 || status === 403) return \"the key can't upload source maps: give its owner the ObsSourceMapUploadAccess policy\"\n if (code === \"debug_id_conflict\") {\n const ids = e.details?.debugIds?.length ? e.details.debugIds.join(\", \") : message\n return `debug ID ${ids} is already registered with different content: rebuild, then upload`\n }\n if (code === \"storage_limit_exceeded\") return \"the project's 10 GiB source-map storage is full: delete old releases (ezgh obs sourcemaps delete)\"\n return `obs-api answered ${status} ${code}: ${message}`\n}\n"
|
|
13
|
+
],
|
|
14
|
+
"mappings": ";AAEA;AACA;;;ACDA,qBAAS;AACT,iBAAS;;;ACCT,eAAsB,oBAAoB,CACxC,GACA,KAC6B;AAAA,EAC7B,MAAM,MAAM,EAAE,UAAU,IAAI;AAAA,EAC5B,IAAI;AAAA,IAAK,OAAO,UAAU;AAAA,EAC1B,QAAgB,8BAAV,KAA2D,gCAAnB,iBAAe;AAAA,EAC7D,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC;AAAA,IAAc;AAAA,EACtC,MAAM,IAAI,EAAE,SAAS;AAAA,EACrB,MAAM,WAAW,EAAE,KAAK,YAAY,EAAE;AAAA,EACtC,MAAM,QAAQ,MAAM,EAAE,GAAG,MAAM,IAAI,SAAS,GAAG,IAAI,MAAM,eAAe,mBAAmB,QAAQ,KAAK;AAAA,IACtG,SAAS,EAAE,eAAe,UA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E,QAAQ,OAAO,MAAO,CAAC;AAAA,OAC9C;AAAA;AAAA,IAEH,MAAM,CAAC,UAAU;AAAA,MAEf,MAAM,IAAI;AAAA,MACV,EAAE,MAAM,UAAU,WAAW,kBAAkB,YAAY;AAAA,QACzD,IAAI,CAAC,aAAa,GAAG,IAAI;AAAA,UAAG;AAAA,QAC5B,MAAM,cAAc,EAAE,QAAQ,OAAO,MAAO,CAAC;AAAA,OAC9C;AAAA;AAAA,IAEH,SAAS;AAAA,MACP,KAAK,CAAC,OAAO;AAAA,QACX,MAAM,MAAM,OAAO,MAAM;AAAA,UACvB,MAAM,KAAK,MAAM;AAAA,UACjB,IAAI,EAAE,OAAO,UAAU,GAAG,UAAU;AAAA,YAAO;AAAA,UAC3C,MAAM,cAAc,GAAG,UAAU,QAAQ,GAAG,OAAQ,GAAG,CAAC;AAAA,SACzD;AAAA;AAAA,IAEL;AAAA,EACF;AAAA,CACD;",
|
|
15
|
+
"debugId": "61B216F94AC531CE64756E2164756E21",
|
|
16
|
+
"names": []
|
|
17
|
+
}
|
package/dist/inject.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { InjectError } from "./errors.ts";
|
|
2
|
+
export { InjectError };
|
|
3
|
+
export interface Injected {
|
|
4
|
+
code: Buffer;
|
|
5
|
+
map: Buffer;
|
|
6
|
+
debugId: string;
|
|
7
|
+
already: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The registration code inserted into every JS file: one line, no newline. It registers the debug
|
|
11
|
+
* ID under the Error stack of the code that runs it, so the SDK maps the script's URL (the stack's
|
|
12
|
+
* first frame) to its debug ID. It never throws.
|
|
13
|
+
*/
|
|
14
|
+
export declare function snippet(id: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* A file pair's debug ID, from its content: SHA-256 of "ezgh-debug-id\0" + js + "\0" + map, the
|
|
17
|
+
* first 16 bytes with the RFC 9562 version (4) and variant bits, as a lowercase UUID.
|
|
18
|
+
*/
|
|
19
|
+
export declare function debugIdFor(js: Uint8Array, map: Uint8Array): string;
|
|
20
|
+
/**
|
|
21
|
+
* Moves every mapping of generated line `line` at column >= `col` right by `delta`. Generated
|
|
22
|
+
* columns are relative within a line, so only the first such segment's first field changes; every
|
|
23
|
+
* other byte of `mappings` stays as it is.
|
|
24
|
+
*/
|
|
25
|
+
export declare function shiftColumns(mappings: string, line: number, col: number, delta: number): string;
|
|
26
|
+
/**
|
|
27
|
+
* Moves the mappings of generated line `line` at column >= `col` to a new line after it, their
|
|
28
|
+
* columns less `col`. Only the first moved segment's generated column changes (the other fields
|
|
29
|
+
* are relative across lines); a line with nothing at `col` or after gains an empty line.
|
|
30
|
+
*/
|
|
31
|
+
export declare function splitLine(mappings: string, line: number, col: number): string;
|
|
32
|
+
/**
|
|
33
|
+
* Adds the debug ID to a JS file and its source map: the snippet after a BOM, a shebang line and
|
|
34
|
+
* the directive prologue (with the map's columns shifted), a `//# debugId=` comment before a
|
|
35
|
+
* trailing `sourceMappingURL` line (or at the end), and the map's `debugId`. `already` is true,
|
|
36
|
+
* with the input unchanged, when all three are there and agree.
|
|
37
|
+
*/
|
|
38
|
+
export declare function injectDebugId(jsBytes: Buffer, mapBytes: Buffer): Injected;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type OidcOptions } from "./auth.ts";
|
|
2
|
+
export interface EzghRumBuildOptions {
|
|
3
|
+
/** Default env EZGH_RUM_APPLICATION; required to upload. */
|
|
4
|
+
application?: string;
|
|
5
|
+
/** Default env EZGH_RUM_RELEASE; required to upload. */
|
|
6
|
+
release?: string;
|
|
7
|
+
/** The organization's UUID; default env EZGH_ORG. */
|
|
8
|
+
organizationId?: string;
|
|
9
|
+
/** The project's UUID; default env EZGH_PROJECT. */
|
|
10
|
+
projectId?: string;
|
|
11
|
+
/** Default env EZGH_API_KEY (setup-ezgh sets it from OIDC). */
|
|
12
|
+
apiKey?: string;
|
|
13
|
+
/** GitHub Actions OIDC → a short-lived bot key, when there's no API key. */
|
|
14
|
+
oidc?: OidcOptions;
|
|
15
|
+
/** Default env EZGH_DOMAIN, else "ezghcloud.com"; uploads go to https://obs.<domain>. */
|
|
16
|
+
domain?: string;
|
|
17
|
+
/** Default true; false only injects. */
|
|
18
|
+
upload?: boolean;
|
|
19
|
+
/** Default true: an error fails the build. False logs it instead. */
|
|
20
|
+
failOnError?: boolean;
|
|
21
|
+
/** Default false (withEzghRum: true): delete the uploaded .map files from the output. */
|
|
22
|
+
deleteMapsAfterUpload?: boolean;
|
|
23
|
+
/** Default: .js, .mjs and .cjs files outside node_modules. */
|
|
24
|
+
include?: (relPath: string) => boolean;
|
|
25
|
+
/** Prefixed to committed paths (withEzghRum: "_next/static/"). */
|
|
26
|
+
pathPrefix?: string;
|
|
27
|
+
/**
|
|
28
|
+
* @internal withEzghRum: delete every .map file of the processed pairs, uploaded or not (it turned
|
|
29
|
+
* productionBrowserSourceMaps on, so maps must never be left to be served).
|
|
30
|
+
*/
|
|
31
|
+
deleteMapsAlways?: boolean;
|
|
32
|
+
/** @internal For tests: the fetch used for obs-api and org-api. */
|
|
33
|
+
fetch?: typeof fetch;
|
|
34
|
+
/** @internal For tests: where log lines go (default console.log). */
|
|
35
|
+
log?: (m: string) => void;
|
|
36
|
+
}
|
|
37
|
+
export declare function processOutput(dir: string, o?: EzghRumBuildOptions): Promise<{
|
|
38
|
+
injected: number;
|
|
39
|
+
uploaded: number;
|
|
40
|
+
}>;
|
package/dist/upload.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const CHUNK_BYTES: number;
|
|
2
|
+
export declare const MISSING_BATCH = 1000;
|
|
3
|
+
export declare const COMMIT_BATCH = 1000;
|
|
4
|
+
export interface UploadFile {
|
|
5
|
+
debugId: string;
|
|
6
|
+
path: string;
|
|
7
|
+
kind: "js" | "map";
|
|
8
|
+
bytes: Uint8Array;
|
|
9
|
+
}
|
|
10
|
+
export interface UploadTarget {
|
|
11
|
+
apiUrl: string;
|
|
12
|
+
organizationId: string;
|
|
13
|
+
projectId: string;
|
|
14
|
+
application: string;
|
|
15
|
+
release: string;
|
|
16
|
+
authorization: string;
|
|
17
|
+
fetch?: typeof fetch;
|
|
18
|
+
log?: (m: string) => void;
|
|
19
|
+
}
|
|
20
|
+
interface ErrorBody {
|
|
21
|
+
code?: string;
|
|
22
|
+
message?: string;
|
|
23
|
+
details?: {
|
|
24
|
+
missing?: string[];
|
|
25
|
+
debugIds?: string[];
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export declare class UploadError extends Error {
|
|
29
|
+
readonly status: number;
|
|
30
|
+
readonly code: string;
|
|
31
|
+
readonly body: ErrorBody;
|
|
32
|
+
name: string;
|
|
33
|
+
constructor(message: string, status: number, code: string, body: ErrorBody);
|
|
34
|
+
}
|
|
35
|
+
export declare function upload(t: UploadTarget, files: readonly UploadFile[]): Promise<{
|
|
36
|
+
files: number;
|
|
37
|
+
chunksUploaded: number;
|
|
38
|
+
}>;
|
|
39
|
+
export {};
|
package/dist/vlq.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ezghcloud/rum-build",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Build plugin for @ezghcloud/rum (Vite, webpack, Rollup, esbuild, Rspack): debug-ID injection and source-map upload to EZGH Observability",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/ezgamehost/ezgh-rum-js.git",
|
|
11
|
+
"directory": "packages/rum-build"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=20.19"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"unplugin": "2.3.10"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"vite": "8.3.1",
|
|
38
|
+
"webpack": "5.102.1",
|
|
39
|
+
"rollup": "4.52.5",
|
|
40
|
+
"esbuild": "0.25.11"
|
|
41
|
+
}
|
|
42
|
+
}
|