@yaks/esbuild 0.0.0-stage → 0.2.36

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.
Files changed (123) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +450 -2
  3. package/_dist/bundle.d.ts +6 -0
  4. package/_dist/bundle.d.ts.map +1 -0
  5. package/_dist/compile.d.ts +72 -0
  6. package/_dist/compile.d.ts.map +1 -0
  7. package/_dist/dependencies.d.ts +15 -0
  8. package/_dist/dependencies.d.ts.map +1 -0
  9. package/_dist/file.d.ts +185 -0
  10. package/_dist/file.d.ts.map +1 -0
  11. package/_dist/graph.d.ts +104 -0
  12. package/_dist/graph.d.ts.map +1 -0
  13. package/_dist/home.d.ts +15 -0
  14. package/_dist/home.d.ts.map +1 -0
  15. package/_dist/link.d.ts +192 -0
  16. package/_dist/link.d.ts.map +1 -0
  17. package/_dist/lock.d.ts +30 -0
  18. package/_dist/lock.d.ts.map +1 -0
  19. package/_dist/mod.d.ts +6 -0
  20. package/_dist/mod.d.ts.map +1 -0
  21. package/_dist/pack.d.ts +42 -0
  22. package/_dist/pack.d.ts.map +1 -0
  23. package/_dist/package.d.ts +11 -0
  24. package/_dist/package.d.ts.map +1 -0
  25. package/_dist/plan.d.ts +135 -0
  26. package/_dist/plan.d.ts.map +1 -0
  27. package/_dist/platform.d.ts +27 -0
  28. package/_dist/platform.d.ts.map +1 -0
  29. package/_dist/resolve.d.ts +42 -0
  30. package/_dist/resolve.d.ts.map +1 -0
  31. package/_dist/shelf.d.ts +11 -0
  32. package/_dist/shelf.d.ts.map +1 -0
  33. package/_dist/strip.d.ts +51 -0
  34. package/_dist/strip.d.ts.map +1 -0
  35. package/_dist/timing.d.ts +6 -0
  36. package/_dist/timing.d.ts.map +1 -0
  37. package/_dist/unpack.d.ts +14 -0
  38. package/_dist/unpack.d.ts.map +1 -0
  39. package/analysis.js +72 -0
  40. package/analysis.js.map +1 -0
  41. package/analysis.ts +82 -0
  42. package/bundle.js +320 -0
  43. package/bundle.js.map +1 -0
  44. package/bundle.ts +415 -0
  45. package/common.js +129 -0
  46. package/common.js.map +1 -0
  47. package/common.ts +138 -0
  48. package/compile.js +500 -0
  49. package/compile.js.map +1 -0
  50. package/compile.ts +622 -0
  51. package/container.js +142 -0
  52. package/container.js.map +1 -0
  53. package/container.ts +183 -0
  54. package/deno.json +1 -0
  55. package/dependencies.js +31 -0
  56. package/dependencies.js.map +1 -0
  57. package/dependencies.ts +40 -0
  58. package/file.js +303 -0
  59. package/file.js.map +1 -0
  60. package/file.ts +443 -0
  61. package/forward.ts +49 -0
  62. package/graph.js +297 -0
  63. package/graph.js.map +1 -0
  64. package/graph.ts +360 -0
  65. package/home.js +40 -0
  66. package/home.js.map +1 -0
  67. package/home.ts +52 -0
  68. package/link.js +455 -0
  69. package/link.js.map +1 -0
  70. package/link.ts +596 -0
  71. package/lock.js +129 -0
  72. package/lock.js.map +1 -0
  73. package/lock.ts +161 -0
  74. package/mod.js +14 -0
  75. package/mod.js.map +1 -0
  76. package/mod.ts +43 -0
  77. package/npm.js +362 -0
  78. package/npm.js.map +1 -0
  79. package/npm.ts +429 -0
  80. package/pack.js +188 -0
  81. package/pack.js.map +1 -0
  82. package/pack.ts +225 -0
  83. package/package.js +199 -0
  84. package/package.js.map +1 -0
  85. package/package.json +60 -4
  86. package/package.ts +255 -0
  87. package/plan.js +273 -0
  88. package/plan.js.map +1 -0
  89. package/plan.ts +395 -0
  90. package/platform.js +160 -0
  91. package/platform.js.map +1 -0
  92. package/platform.ts +238 -0
  93. package/resolve.js +86 -0
  94. package/resolve.js.map +1 -0
  95. package/resolve.ts +144 -0
  96. package/said.js +44 -0
  97. package/said.js.map +1 -0
  98. package/said.ts +61 -0
  99. package/serve.ts +37 -0
  100. package/sha256.js +7 -0
  101. package/sha256.js.map +1 -0
  102. package/sha256.ts +10 -0
  103. package/shared.js +646 -0
  104. package/shared.js.map +1 -0
  105. package/shared.ts +813 -0
  106. package/shelf.js +73 -0
  107. package/shelf.js.map +1 -0
  108. package/shelf.ts +110 -0
  109. package/strip.js +114 -0
  110. package/strip.js.map +1 -0
  111. package/strip.ts +117 -0
  112. package/tar.js +87 -0
  113. package/tar.js.map +1 -0
  114. package/tar.ts +99 -0
  115. package/timing.js +37 -0
  116. package/timing.js.map +1 -0
  117. package/timing.ts +71 -0
  118. package/unpack.js +40 -0
  119. package/unpack.js.map +1 -0
  120. package/unpack.ts +60 -0
  121. package/used.js +91 -0
  122. package/used.js.map +1 -0
  123. package/used.ts +116 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.d.ts","sources":["../bundle.ts"],"names":[],"mappings":"AAuEA;;0CAE0C,GAC1C,OAAO,cAAM,gBAAgB;EAClB,aAAgB;AAC3B"}
@@ -0,0 +1,72 @@
1
+ import { type Answer, type Ask } from "./plan.js";
2
+ import { type Shelves } from "./shelf.js";
3
+ import { type Catalog, type Toolkit } from "./platform.js";
4
+ import { type Compiled } from "./package.js";
5
+ export type { Catalog, Toolkit } from "./platform.js";
6
+ export { Stopped } from "./bundle.js";
7
+ /** What a host posts to the compiler's server: the app's ask, and beside it
8
+ * the toolkit catalog, which the host supplies and an app never does. */ export type Job = {
9
+ ask: Ask;
10
+ catalog: Catalog;
11
+ origin?: string;
12
+ /** The host can store and serve content-addressed browser modules. */ shared?: boolean;
13
+ };
14
+ /** What a host posts to have one package version compiled for the whole
15
+ * platform (D-499): an npm package at an exact version, or a toolkit
16
+ * package at its catalog version, with its sources. */ export type PackageJob = {
17
+ package: {
18
+ name: string;
19
+ version: string;
20
+ toolkit?: Toolkit;
21
+ /** A specifier a pattern export matches, built alone. */ subpath?: string;
22
+ };
23
+ origin: string;
24
+ };
25
+ /** A package compiled for the platform, and the tarball each npm package
26
+ * home its modules name is filled from, by its SHA-256 (./home.ts). */ export type CompiledPackage = Compiled & {
27
+ tarballs: Record<string, string>;
28
+ };
29
+ /** Compile one package version on its own (./package.ts): nothing it
30
+ * imports is installed, since every import of another package stays bare.
31
+ * A toolkit package's resources are kept beside its modules, under its
32
+ * package's name; an npm package's are served from its home on `origin`. */ export declare let compilePackage: ({}: PackageJob, _dts_1: never) => Promise<CompiledPackage>;
33
+ /** The module a compiled worker is uploaded as: its source's path, as
34
+ * JavaScript.
35
+ *
36
+ * ```ts
37
+ * import { assertEquals } from '@std/assert'
38
+ * assertEquals(compiledName('src/worker.ts'), 'src/worker.js')
39
+ * assertEquals(compiledName('worker.mjs'), 'worker.mjs')
40
+ * ```
41
+ */ export declare let compiledName: (entry: string) => string;
42
+ /** The modules a page imports statically that no browser has: Node's
43
+ * built-ins, which a module written for the toolkit's other hosts can reach.
44
+ * A browser links a page's whole static graph before it runs a line of it, so
45
+ * one such import anywhere in the graph stops the page (yak.sh v50, whose
46
+ * @yaks/cli/terminal reached node:fs). `code` is the page as served, with
47
+ * every shared module it reaches named ({@link flat}); a dynamic import is
48
+ * fetched only when it runs, so the code that asks for it decides. */ export declare let browserless: (code: string) => string[];
49
+ /** The pages that share one pack: those an HTML page loads together, joined
50
+ * through a page two HTML pages load. */ export declare let realms: (pages: string[], together?: string[][]) => string[][];
51
+ /** Compile what an ask names. Never throws for the app's own mistakes: those
52
+ * are the answer's `errors`. Throws {@link Stopped} when esbuild's process
53
+ * ends under a build, which is the compiler's room and not the app's code.
54
+ * The host supplies its toolkit catalog separately from the app's ask, and
55
+ * `get` is how the npm registry is fetched. */ export declare let compile: (ask: Ask, catalog?: Catalog, origin?: string, options?: {
56
+ shared?: boolean;
57
+ get?: typeof fetch;
58
+ timing?: boolean;
59
+ shelves?: Shelves;
60
+ }) => Promise<Answer>;
61
+ /** Forget every cache memory holds, as a container that restarts does: the
62
+ * shelves are what is left. */ export declare let forget: () => void;
63
+ type FetchJob = (req: Request) => Promise<Response>;
64
+ /** The compiler's server, every answer sealed with its body's digest
65
+ * (./container.ts `sealed`). Losing the esbuild subprocess interrupts the job.
66
+ * esbuild's API reports a closed service channel without an exit reason.
67
+ * `shelves` keep what it fetches and builds beyond its container. */ export declare let serving: (build?: typeof compile, shelves?: Shelves) => FetchJob;
68
+ declare let server: {
69
+ fetch: FetchJob;
70
+ };
71
+ export default server;
72
+ //# sourceMappingURL=compile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.d.ts","sources":["../compile.ts"],"names":[],"mappings":"AAuBA,SAAS,KAAK,MAAM,EAAE,KAAK,GAAG,oBAAiC;AAW/D,SAAS,KAAK,OAAO,qBAA2B;AAEhD,SACE,KAAK,OAAO,EAKZ,KAAK,OAAO,wBAEQ;AAEtB,SAAS,KAAK,QAAQ,uBAAsC;AAG5D,cAAc,OAAO,EAAE,OAAO,wBAAuB;AACrD,SAAS,OAAO,sBAAqB;AAErC;uEACuE,GACvE,YAAY;EACV,KAAK;EACL,SAAS;EACT,SAAS,MAAM;EACf,oEAAoE,GACpE,SAAS,OAAO;;AAGlB;;qDAEqD,GACrD,YAAY;EACV;IACE,MAAM,MAAM;IACZ,SAAS,MAAM;IACf,UAAU;IACV,uDAAuD,GACvD,UAAU,MAAM;;EAElB,QAAQ,MAAM;;AAGhB;qEACqE,GACrE,YAAY,kBAAkB;EAAa,UAAU,OAAO,MAAM,EAAE,MAAM;;AAE1E;;;0EAG0E,GAC1E,OAAO,YAAI,iBACT,IAA0D,UAAU,EACpE,kBACC,QAAQ,iBA2CV;AAED;;;;;;;;CAQC,GACD,OAAO,YAAI,eAAgB,OAAO,MAAM,KAAG,MAAM,CACM;AAmHvD;;;;;;oEAMoE,GACpE,OAAO,YAAI,cAAe,MAAM,MAAM,KAAG,MAAM,GAM9C;AAiCD;uCACuC,GACvC,OAAO,YAAI,SACT,OAAO,MAAM,IACb,WAAU,MAAM,SACf,MAAM,KAOR;AAWD;;;;6CAI6C,GAC7C,OAAO,YAAI,UACT,KAAK,KACL,UAAS,SACT,iBACA;EACE,SAAS,OAAO;EAChB,aAAa;EACb,SAAS,OAAO;EAChB,UAAU;MAEX,QAAQ,QAsLV;AAED;6BAC6B,GAC7B,OAAO,YAAI,cAAa,IAAI,CAG3B;KAEI,YAAY,KAAK,YAAY,QAAQ;AAE1C;;;mEAGmE,GACnE,OAAO,YAAI,UACT,eAAc,SACd,UAAU,YACT,SACuD;AA8E1D,YAAI;EAAU,OAAO;;AACrB,eAAe,OAAM"}
@@ -0,0 +1,15 @@
1
+ /** A plan that cannot be made, in a sentence the agent can act on. */ export declare class Unplanned extends Error {
2
+ name: string;
3
+ }
4
+ /** The packages package.json declares, name to version range; none without
5
+ * one.
6
+ *
7
+ * ```ts
8
+ * import { assertEquals } from '@std/assert'
9
+ * assertEquals(dependencies('{"dependencies": {"three": "^0.180.0"}}'), {
10
+ * three: '^0.180.0',
11
+ * })
12
+ * assertEquals(dependencies(null), {})
13
+ * ```
14
+ */ export declare let dependencies: (text: string | null) => Record<string, string>;
15
+ //# sourceMappingURL=dependencies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencies.d.ts","sources":["../dependencies.ts"],"names":[],"mappings":"AAIA,oEAAoE,GACpE,OAAO,cAAM,kBAAkB;EACpB,aAAkB;AAC7B;AAEA;;;;;;;;;;CAUC,GACD,OAAO,YAAI,eAAgB,MAAM,MAAM,GAAG,IAAI,KAAG,OAAO,MAAM,EAAE,MAAM,EAmBrE"}
@@ -0,0 +1,185 @@
1
+ /** What the compile makes, as a number: output kept under another is made
2
+ * again. Raise it whenever the same source would compile to other bytes. */ export declare let COMPILER: number;
3
+ /** What compiling one of an app's files makes (./strip.ts `compiled`), as a
4
+ * number, apart from `COMPILER`, which names every package's modules too:
5
+ * a file kept under another is compiled again. */ export declare let FILE_COMPILER: number;
6
+ /** What a pack of an app's own modules makes (./pack.ts), as a number: a
7
+ * pack kept under another is made again. Raise it whenever the same modules
8
+ * would pack to other bytes. */ export declare let PACKER: number;
9
+ /** How a file compiles beyond what its path says: the package an app's JSX
10
+ * is automatic from (`preact`, `react`), or classic `React.createElement`
11
+ * where none. */ export type FileOptions = {
12
+ jsxImportSource?: string;
13
+ };
14
+ /** What a file is by its path: `ts`, `tsx`, `jsx` and their kin compile,
15
+ * anything else is JavaScript as written. */ export declare let kindOf: (path: string) => string;
16
+ /** A source's address: the SHA-256 of its bytes, in hex. */ export declare let addressOf: (source: string) => Promise<string>;
17
+ /** The name a file's compiled output is kept under, from its source's
18
+ * address: one name for one output, whichever app or path holds the source.
19
+ *
20
+ * ```ts
21
+ * import { assertEquals, assertNotEquals } from '@std/assert'
22
+ * let x = await addressOf('x')
23
+ * assertEquals(await compiledName('a.ts', x), await compiledName('b/c.ts', x))
24
+ * assertNotEquals(await compiledName('a.ts', x), await compiledName('a.tsx', x))
25
+ * assertNotEquals(
26
+ * await compiledName('a.tsx', x),
27
+ * await compiledName('a.tsx', x, { jsxImportSource: 'preact' }),
28
+ * )
29
+ * ```
30
+ */ export declare let compiledName: (path: string, address: string, _dts_1: never) => Promise<string>;
31
+ /** Where compiled output is kept: by name, written once, never changed. */ export type Keep = {
32
+ has: (name: string) => Promise<boolean>;
33
+ put: (name: string, code: string) => Promise<void>;
34
+ };
35
+ /** Where package modules are kept in a byte store, whichever host: every
36
+ * app's, under one prefix, since a name is the same output in any of them,
37
+ * and served to anyone at `MODULES_AT`. */ export declare let MODULES: string;
38
+ /** Where an app's own compiled scripts are kept: once for every app, as
39
+ * package modules are, but apart from them, so `MODULES_AT` never answers
40
+ * one. An app serves its own at its scripts' paths, behind its own access. */ export declare let APP_MODULES: string;
41
+ /** Where a host serves what it keeps under `MODULES`, from its one origin,
42
+ * so every app's pages share one cache of each. */ export declare let MODULES_AT: string;
43
+ /** A `Keep` over a byte store (@yaks/blob's, a bucket's), each module at
44
+ * `MODULES` + its name + `.js`. */ export declare let keptIn: (store: {
45
+ has: (key: string) => Promise<boolean>;
46
+ put: (key: string, bytes: Uint8Array) => Promise<unknown>;
47
+ }) => Keep;
48
+ /** A file to compile: its path, its source's address, and its source, read
49
+ * only when it compiles. */ export type Source = {
50
+ path: string;
51
+ address: string;
52
+ read: () => string | Promise<string>;
53
+ };
54
+ /** Sources held as text, each addressed. */ export declare let sourcesOf: (files: {
55
+ path: string;
56
+ source: string;
57
+ }[]) => Promise<Source[]>;
58
+ /** Compiles one file (./strip.ts `compiled`, or a host that runs it). */ export type Compile = (path: string, source: string, options: FileOptions) => string | Promise<string>;
59
+ /** Each file's compiled name, compiling and keeping only output nobody kept
60
+ * before. `known` names output kept already (the release before's), taken at
61
+ * its word, its source never read; any other name costs one `has`, and a miss
62
+ * a read, a compile and a `put`. Six at once, as a Worker holds six
63
+ * connections. */ export declare let compiledFiles: (files: Source[], keep: Keep, compile: Compile, _dts_2: never) => Promise<Map<string, string>>;
64
+ /** What names a package's compile: `name@version`, and after it the rest of
65
+ * a specifier a pattern export matches, built alone (./package.ts).
66
+ *
67
+ * ```ts
68
+ * import { assertEquals } from '@std/assert'
69
+ * assertEquals(packageKey('three', '0.180.0'), 'three@0.180.0')
70
+ * assertEquals(
71
+ * packageKey('three', '0.180.0', 'three/addons/controls/OrbitControls.js'),
72
+ * 'three@0.180.0/addons/controls/OrbitControls.js',
73
+ * )
74
+ * ```
75
+ */ export declare let packageKey: (name: string, version: string, subpath?: string) => string;
76
+ /** The name a package version's compile is kept under (./package.ts), from
77
+ * its key (`packageKey`): its record of entries is `<name>.json` beside its
78
+ * modules.
79
+ *
80
+ * ```ts
81
+ * import { assertNotEquals } from '@std/assert'
82
+ * assertNotEquals(
83
+ * await packageName('preact@10.26.0'),
84
+ * await packageName('preact@10.26.1'),
85
+ * )
86
+ * ```
87
+ */ export declare let packageName: (key: string) => Promise<string>;
88
+ /** What a package version's modules are kept in: a byte store's reads and
89
+ * writes, by key. */ export type Kept = {
90
+ read: (key: string) => Promise<Uint8Array | null>;
91
+ put: (key: string, bytes: Uint8Array) => Promise<unknown>;
92
+ };
93
+ /** A specifier no export of its package names: nothing to compile. */ export declare class Unexported extends Error {
94
+ name: string;
95
+ }
96
+ /** What is kept of a package's compile: each entry's specifier and its
97
+ * module file, the bare specifiers its modules import, and what each module
98
+ * imports statically (@yaks/esbuild/package `Compiled`). */ export type KeptPackage = {
99
+ entries: Record<string, string>;
100
+ imports: string[];
101
+ links: Record<string, string[]>;
102
+ };
103
+ /** A package version's entries and imports, compiled once for the platform:
104
+ * read from its record in `store`, or compiled, every module kept, and then
105
+ * the record, so a record names only modules that are there. A record from
106
+ * before it said its imports and links is compiled again. */ export declare let keptPackage: (store: Kept, key: string, compile: () => Promise<KeptPackage & {
107
+ modules: Record<string, string>;
108
+ }>) => Promise<KeptPackage>;
109
+ /** A kept module, or a package's resource, at `file` under `MODULES_AT`, for
110
+ * every app and every page: immutable, since a name is written once, and
111
+ * readable from any origin. Null when nothing is kept there. */ export declare let servedModule: (store: Pick<Kept, 'read'>, file: string) => Promise<Response | null>;
112
+ /** What a page's import map names for the bare specifiers its modules
113
+ * import: each entry of each package an app's release uses (`packages`, as
114
+ * `keptPackage` keeps them), at `origin` + `MODULES_AT`, and each alias its
115
+ * renderer gives (`react` for `preact/compat`) at its target's address.
116
+ *
117
+ * ```ts
118
+ * import { assertEquals } from '@std/assert'
119
+ * assertEquals(
120
+ * bareMap(
121
+ * [{ entries: { preact: 'a.js', 'preact/compat': 'b.js' } }],
122
+ * { react: 'preact/compat', 'react-dom': 'preact/compat', x: 'gone' },
123
+ * 'https://yaks.app',
124
+ * ),
125
+ * {
126
+ * preact: 'https://yaks.app/__m/a.js',
127
+ * 'preact/compat': 'https://yaks.app/__m/b.js',
128
+ * react: 'https://yaks.app/__m/b.js',
129
+ * 'react-dom': 'https://yaks.app/__m/b.js',
130
+ * },
131
+ * )
132
+ * ```
133
+ */ export declare let bareMap: (packages: Pick<KeptPackage, 'entries'>[], aliases: Readonly<Record<string, string>> | undefined, origin: string) => Record<string, string>;
134
+ /** What the app's script at `path` imports statically, read from its
135
+ * compiled module `js`, as a release's module graph names it: another of
136
+ * the app's `scripts` as `./<path>` from the app's root, found as a compile
137
+ * finds it (`./lib/n` loads lib/n.ts), and a bare specifier as written. The
138
+ * module is lexed, so an import in a comment or a string names nothing; it
139
+ * is the compiled module, so the JSX runtime the compiler writes in is named
140
+ * and an `import type` is gone. `import('x')` loads only when it runs. An
141
+ * address none of the app's scripts is, or a module that does not lex, names
142
+ * nothing.
143
+ *
144
+ * ```ts
145
+ * import { assertEquals } from '@std/assert'
146
+ * assertEquals(
147
+ * scriptLinks(
148
+ * 'ui/main.ts',
149
+ * "import { a } from '../lib/a.ts'\nexport * from 'preact'\n" +
150
+ * "import { b } from '../lib/b'\n" +
151
+ * "export let n = {}\n// import { f } from './f.ts'\n" +
152
+ * "let later = () => import('./late.ts')",
153
+ * new Set(['lib/a.ts', 'lib/b.tsx', 'ui/f.ts', 'ui/late.ts']),
154
+ * ),
155
+ * ['./lib/a.ts', 'preact', './lib/b.tsx'],
156
+ * )
157
+ * ```
158
+ */ export declare let scriptLinks: (path: string, js: string, scripts: ReadonlySet<string>) => string[];
159
+ /** Each path from the app's root that the script at `path` imports, by
160
+ * `import` or `import()`, naming none of the app's `scripts` but one a
161
+ * compile finds (./graph.ts `found`), with the script it loads: what a
162
+ * page's map names so the browser loads it there.
163
+ *
164
+ * ```ts
165
+ * import { assertEquals } from '@std/assert'
166
+ * assertEquals(
167
+ * looseImports('main.ts', "import './lib/n'\nimport('./ui')\n" +
168
+ * "import './lib/n.ts'", new Set(['lib/n.ts', 'ui/index.ts'])),
169
+ * { 'lib/n': 'lib/n.ts', ui: 'ui/index.ts' },
170
+ * )
171
+ * ```
172
+ */ export declare let looseImports: (path: string, js: string, scripts: ReadonlySet<string>) => Record<string, string>;
173
+ /** Each kept module of `packages` by its address under `origin`, and what it
174
+ * imports statically: the package's other modules by their addresses, and
175
+ * bare specifiers as written (@yaks/esbuild/package `Compiled`).
176
+ *
177
+ * ```ts
178
+ * import { assertEquals } from '@std/assert'
179
+ * assertEquals(
180
+ * packageLinks([{ links: { 'a.js': ['./b.js', 'preact'] } }], 'https://y'),
181
+ * { 'https://y/__m/a.js': ['https://y/__m/b.js', 'preact'] },
182
+ * )
183
+ * ```
184
+ */ export declare let packageLinks: (packages: Pick<KeptPackage, 'links'>[], origin: string) => Record<string, string[]>;
185
+ //# sourceMappingURL=file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sources":["../file.ts"],"names":[],"mappings":"AAgBA;0EAC0E,GAC1E,OAAO,YAAI,iBAAY;AAEvB;;gDAEgD,GAChD,OAAO,YAAI,sBAAiB;AAE5B;;8BAE8B,GAC9B,OAAO,YAAI,eAAU;AAErB;;eAEe,GACf,YAAY;EAAgB,kBAAkB,MAAM;;AAEpD;2CAC2C,GAC3C,OAAO,YAAI,SAAU,MAAM,MAAM,KAAG,MAAM,CACH;AAWvC,0DAA0D,GAC1D,OAAO,YAAI,YAAa,QAAQ,MAAM,KAAG,QAAQ,MAAM,EACb;AAE1C;;;;;;;;;;;;;CAaC,GACD,OAAO,YAAI,eACT,MAAM,MAAM,EACZ,SAAS,MAAM,EACf,kBACC,QAAQ,MAAM,EAOhB;AAED,yEAAyE,GACzE,YAAY;EACV,MAAM,MAAM,MAAM,KAAK,QAAQ,OAAO;EACtC,MAAM,MAAM,MAAM,EAAE,MAAM,MAAM,KAAK,QAAQ,IAAI;;AAGnD;;yCAEyC,GACzC,OAAO,YAAI,gBAAoB;AAE/B;;4EAE4E,GAC5E,OAAO,YAAI,oBAA4B;AAEvC;iDACiD,GACjD,OAAO,YAAI,mBAAoB;AAE/B;iCACiC,GACjC,OAAO,YAAI,SACT;EACE,MAAM,KAAK,MAAM,KAAK,QAAQ,OAAO;EACrC,MAAM,KAAK,MAAM,EAAE,OAAO,eAAe,QAAQ,OAAO;MAGzD,KAKD;AAEF;0BAC0B,GAC1B,YAAY;EACV,MAAM,MAAM;EACZ,SAAS,MAAM;EACf,YAAY,MAAM,GAAG,QAAQ,MAAM;;AAGrC,0CAA0C,GAC1C,OAAO,YAAI,YACT;EAAS,MAAM,MAAM;EAAE,QAAQ,MAAM;QACpC,QAAQ,UAKL;AAEN,uEAAuE,GACvE,YAAY,WACV,MAAM,MAAM,EACZ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1B,MAAM,GAQR;AAED;;;;;;;;;;;;;CAaC,GACD,OAAO,YAAI,eACT,MAAM,MAAM,EACZ,IAAI,MAAM,EACV,SAAS,YAAY,MAAM,MAC1B,OAAO,MAAM,EAAE,MAAM,EAKrB;AAEH;;;;;;;;;;;CAWC,GACD,OAAO,YAAI,eACT,UAAU,KAAK,aAAa,YAC5B,QAAQ,MAAM,KACb,OAAO,MAAM,EAAE,MAAM,IAUrB"}
@@ -0,0 +1,104 @@
1
+ /** An app file's bytes, or null when the app has no file at that path. */ export type Read = (path: string) => Promise<Uint8Array<ArrayBuffer> | null>;
2
+ /** What an entry reaches. `files` is every app file, entry first; a file that
3
+ * is not a script is a leaf, since its imports are not ours to follow. */ export type Reached = {
4
+ files: Map<string, Uint8Array<ArrayBuffer>>;
5
+ /** App paths imported with `type: 'text'`, regardless of extension. */ texts: Set<string>;
6
+ /** App paths imported without the text loader. */ linked: Set<string>;
7
+ /** Every specifier that is not a path: `three`, `hono/cors`, `node:fs`. */ named: string[];
8
+ /** Each Web Worker a reached file starts from the app's files, as the file
9
+ * that starts it and the specifier it names: an entry of its own, which the
10
+ * walk does not follow. What the specifier resolves against depends on
11
+ * whether that file is compiled (./plan.ts). */ started: [string, string][];
12
+ };
13
+ /** TypeScript or JSX as the JavaScript it becomes, every import kept, read
14
+ * by what its path says it is; JavaScript as it is written. Throws a
15
+ * SyntaxError where the source does not parse. `./strip` is sucrase's, at
16
+ * once; a host may answer from elsewhere, later. */ export type Strip = (path: string, source: string) => string | Promise<string>;
17
+ /** The specifiers a script starts as Web Workers, read by their shape alone,
18
+ * so TypeScript reads as well as JavaScript.
19
+ *
20
+ * ```ts
21
+ * import { assertEquals } from '@std/assert'
22
+ * assertEquals(
23
+ * startsIn("new Worker(new URL('./grow.ts', import.meta.url), {})"),
24
+ * ['./grow.ts'],
25
+ * )
26
+ * ```
27
+ */ export declare let startsIn: (code: string) => string[];
28
+ /** The specifiers a module imports, in reading order, or none when it does
29
+ * not parse. Its path says how to read it: TypeScript or JSX through `strip`,
30
+ * JavaScript as it is.
31
+ *
32
+ * ```ts
33
+ * import { assertEquals } from '@std/assert'
34
+ * import { strip } from '@yaks/esbuild/strip'
35
+ * assertEquals(
36
+ * await specifiers(
37
+ * 'a.tsx',
38
+ * `// import x from 'said'\nimport type { T } from 'types'\n` +
39
+ * `import a from './a.js'\nexport * from "three"\n` +
40
+ * `let b = <b>it's</b>\nimport('./b')`,
41
+ * strip,
42
+ * ),
43
+ * ['./a.js', 'three', './b'],
44
+ * )
45
+ * assertEquals(await specifiers('a.ts', 'let n: = 1', strip), [])
46
+ * ```
47
+ */ export declare let specifiers: (path: string, source: string, strip: Strip) => Promise<string[]>;
48
+ /** The specifiers of the scripts a module starts as Web Workers.
49
+ *
50
+ * ```ts
51
+ * import { assertEquals } from '@std/assert'
52
+ * import { strip } from '@yaks/esbuild/strip'
53
+ * assertEquals(
54
+ * await started(
55
+ * 'main.ts',
56
+ * `let w: Worker = new Worker(new URL('./grow.ts', import.meta.url), ` +
57
+ * `{ type: 'module' })\nnew SharedWorker(new URL("../hub.js", ` +
58
+ * `import.meta.url))\nnew Worker('plain.js')`,
59
+ * strip,
60
+ * ),
61
+ * ['./grow.ts', '../hub.js'],
62
+ * )
63
+ * ```
64
+ */ export declare let started: (path: string, source: string, strip: Strip) => Promise<string[]>;
65
+ /** Whether a specifier names a file of the app rather than a package. */ export declare let relative: (spec: string) => boolean;
66
+ /** The npm package a specifier names, or null when it names none.
67
+ *
68
+ * ```ts
69
+ * import { assertEquals } from '@std/assert'
70
+ * assertEquals(packageOf('three/examples/jsm/Addons.js'), 'three')
71
+ * assertEquals(packageOf('@hono/zod-validator'), '@hono/zod-validator')
72
+ * assertEquals(packageOf('node:fs'), null)
73
+ * assertEquals(packageOf('./a.js'), null)
74
+ * ```
75
+ */ export declare let packageOf: (spec: string) => string | null;
76
+ /**
77
+ * A specifier against the module that named it: module names are the app's
78
+ * own paths, so `./lib.wasm` from `worker.js` is `lib.wasm` and `../lib.wasm`
79
+ * from `a/b.js` is `lib.wasm`. `..` past the top pops nothing, so no
80
+ * specifier names a file outside the app.
81
+ *
82
+ * ```ts
83
+ * import { assertEquals } from '@std/assert'
84
+ * assertEquals(resolved('a/b.js', '../lib.wasm'), 'lib.wasm')
85
+ * assertEquals(resolved('worker.js', '../../x.js'), 'x.js')
86
+ * ```
87
+ */ export declare let resolved: (from: string, spec: string) => string;
88
+ /** Whether a path is a module with imports of its own to follow. */ export declare let script: (path: string) => boolean;
89
+ /** Whether a path is TypeScript or JSX, which only a compiler runs. */ export declare let typed: (path: string) => boolean;
90
+ /** The TypeScript files a JavaScript path names by TypeScript's convention.
91
+ *
92
+ * ```ts
93
+ * import { assertEquals } from '@std/assert'
94
+ * assertEquals(twins('lib/util.js'), ['lib/util.ts', 'lib/util.tsx'])
95
+ * assertEquals(twins('util.ts'), [])
96
+ * ```
97
+ */ export declare let twins: (path: string) => string[];
98
+ /** A walk of the module graph from one entry. */ export type Walk = (read: Read, entry: string) => Promise<Reached>;
99
+ /** What the runtime loads from `entry`: each specifier names a file exactly,
100
+ * and only JavaScript is linked, so a TypeScript or JSX file is a leaf. */ export declare let modules: Walk;
101
+ /** What esbuild compiles from `entry`, reading TypeScript and JSX through
102
+ * `strip`: an import may leave off the extension or name a directory's
103
+ * index. */ export declare let sources: (strip: Strip) => Walk;
104
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sources":["../graph.ts"],"names":[],"mappings":"AAiBA,wEAAwE,GACxE,YAAY,QAAQ,MAAM,MAAM,KAAK,QAAQ,WAAW,eAAe,IAAI;AAE3E;wEACwE,GACxE,YAAY;EACV,OAAO,IAAI,MAAM,EAAE,WAAW;EAC9B,qEAAqE,GACrE,OAAO,IAAI,MAAM;EACjB,gDAAgD,GAChD,QAAQ,IAAI,MAAM;EAClB,yEAAyE,GACzE,OAAO,MAAM;EACb;;;gDAG8C,GAC9C,UAAU,MAAM,EAAE,MAAM;;AAG1B;;;kDAGkD,GAClD,YAAY,SAAS,MAAM,MAAM,EAAE,QAAQ,MAAM,KAAK,MAAM,GAAG,QAAQ,MAAM;AAa7E;;;;;;;;;;CAUC,GACD,OAAO,YAAI,WAAY,MAAM,MAAM,KAAG,MAAM,GACC;AAkC7C;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,YAAI,aACT,MAAM,MAAM,EACZ,QAAQ,MAAM,EACd,OAAO,UACN,QAAQ,MAAM,IACmD;AAEpE;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,YAAI,UACT,MAAM,MAAM,EACZ,QAAQ,MAAM,EACd,OAAO,UACN,QAAQ,MAAM,IAAiD;AAElE,uEAAuE,GACvE,OAAO,YAAI,WAAY,MAAM,MAAM,KAAG,OAAO,CACI;AAMjD;;;;;;;;;CASC,GACD,OAAO,YAAI,YAAa,MAAM,MAAM,KAAG,MAAM,GAAG,IAAI,CAInD;AAED;;;;;;;;;;;CAWC,GACD,OAAO,YAAI,WAAY,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,MAAM,CAQzD;AAMD,kEAAkE,GAClE,OAAO,YAAI,SAAU,MAAM,MAAM,KAAG,OAAO,CAAqB;AAEhE,qEAAqE,GACrE,OAAO,YAAI,QAAS,MAAM,MAAM,KAAG,OAAO,CAAoB;AAa9D;;;;;;;CAOC,GACD,OAAO,YAAI,QAAS,MAAM,MAAM,KAAG,MAAM,GAIxC;AAqCD,+CAA+C,GAC/C,YAAY,QAAQ,MAAM,MAAM,OAAO,MAAM,KAAK,QAAQ;AAqF1D;yEACyE,GACzE,OAAO,YAAI,SAAS,KAAkB;AAEtC;;UAEU,GACV,OAAO,YAAI,UAAW,OAAO,UAAQ,KAA0B"}
@@ -0,0 +1,15 @@
1
+ /** Where packages come from. */ export declare let REGISTRY: string;
2
+ /** The home a tarball's files are served from, under the host's
3
+ * `__packages/` root.
4
+ *
5
+ * ```ts
6
+ * import { assertEquals } from '@std/assert'
7
+ * assertEquals(homeOf('ab'.repeat(32)), `__packages/${'ab'.repeat(32)}/`)
8
+ * ```
9
+ */ export declare let homeOf: (sha256: string) => string;
10
+ /** Where an installed package came from: its registry tarball, and the
11
+ * SHA-256 of that tarball's bytes, which names the package's home. */ export type Tarball = {
12
+ url: string;
13
+ sha256: string;
14
+ };
15
+ //# sourceMappingURL=home.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"home.d.ts","sources":["../home.ts"],"names":[],"mappings":"AAWA,8BAA8B,GAC9B,OAAO,YAAI,iBAAuC;AAElD;;;;;;;CAOC,GACD,OAAO,YAAI,SAAU,QAAQ,MAAM,YAA4B;AAE/D;oEACoE,GACpE,YAAY;EAAY,KAAK,MAAM;EAAE,QAAQ,MAAM"}
@@ -0,0 +1,192 @@
1
+ import type { Keep } from "./file.js";
2
+ /** A module in a graph: an app's script by `./<path>` from the app's root,
3
+ * or a package module by its address. */ export type Node = string;
4
+ /** What each module's specifiers resolve to, by node: a specifier as written
5
+ * and the node it names. A specifier missing from a module's entry is left as
6
+ * written (`cloudflare:workers`, an address). */ export type Edges = Record<Node, Record<string, Node>>;
7
+ /** Each literal specifier a module imports, statically or by `import()`, in
8
+ * reading order.
9
+ *
10
+ * ```ts
11
+ * import { assertEquals } from '@std/assert'
12
+ * assertEquals(
13
+ * specifiersOf(
14
+ * "import a from './a.js'\nexport * from 'b'\n" +
15
+ * "let c = import('./c.js'), d = import(name)",
16
+ * ),
17
+ * ['./a.js', 'b', './c.js'],
18
+ * )
19
+ * ```
20
+ */ export declare let specifiersOf: (code: string) => string[];
21
+ /** `code` with each specifier `to` answers for written as its answer, and
22
+ * every other one as it was.
23
+ *
24
+ * ```ts
25
+ * import { assertEquals } from '@std/assert'
26
+ * assertEquals(
27
+ * rewritten("import a from 'a'\nimport('./b.js')\nimport 'c'", (spec) =>
28
+ * spec == 'c' ? undefined : `/x/${spec}`),
29
+ * "import a from '/x/a'\nimport(\"/x/./b.js\")\nimport 'c'",
30
+ * )
31
+ * ```
32
+ */ export declare let rewritten: (code: string, to: (spec: string) => string | undefined) => string;
33
+ /** Whether a specifier is bare: no path and no scheme, so only a map or a
34
+ * linker says what it names. */ export declare let bare: (spec: string) => boolean;
35
+ /** What linking makes, as a number: raise it whenever the same graph would
36
+ * link to other bytes. */ export declare let LINKER: number;
37
+ /**
38
+ * Each module `roots` reach, by node, and the name of it linked: a digest of
39
+ * the module's own name (`nameOf`, the name its bytes are kept under) and of
40
+ * everything it reaches, edges included. A module that must be linked is an
41
+ * app's (`own`), one with a bare specifier, or one that reaches either; any
42
+ * other keeps its own name. Cycles are named together, each member by the
43
+ * whole cycle.
44
+ *
45
+ * ```ts
46
+ * import { assertEquals, assertNotEquals } from '@std/assert'
47
+ * let own = (node: string) => node.startsWith('./')
48
+ * let edges = {
49
+ * './a.ts': { './b.ts': './b.ts', p: 'https://y/p.js' },
50
+ * './b.ts': {},
51
+ * 'https://y/p.js': {},
52
+ * }
53
+ * let names = await linkNames(['./a.ts'], edges, (n) => n.length + n, own)
54
+ * assertEquals(names.get('https://y/p.js'), '14https://y/p.js')
55
+ * let moved = await linkNames(['./a.ts'], edges, (n) => n + '!', own)
56
+ * assertNotEquals(names.get('./a.ts'), moved.get('./a.ts'))
57
+ * ```
58
+ */ export declare let linkNames: (roots: Node[], edges: Edges, nameOf: (node: Node) => string, own: (node: Node) => boolean) => Promise<Map<Node, string>>;
59
+ /** `code` with the attributes of its static imports dropped, and the type
60
+ * each of those imports named (`json`, `text`), by specifier: the file it
61
+ * names is uploaded as a module of that value. Null when an import names
62
+ * another type, or a dynamic import names any.
63
+ *
64
+ * ```ts
65
+ * import { assertEquals } from '@std/assert'
66
+ * assertEquals(
67
+ * unattributed("import w from './w.json' with { type: 'json' }\nlet n = 1"),
68
+ * { code: "import w from './w.json'\nlet n = 1", typed: { './w.json': 'json' } },
69
+ * )
70
+ * assertEquals(unattributed("import a from './a.css' with { type: 'css' }"), null)
71
+ * ```
72
+ */ export declare let unattributed: (code: string) => {
73
+ code: string;
74
+ typed: Record<string, string>;
75
+ } | null;
76
+ /** The graph `roots` reach: each module's specifiers, as `specs` answers
77
+ * them (from what a host kept before, or by reading the module), and what
78
+ * each resolves to, as `resolve` says. A specifier it leaves undefined is
79
+ * left as written and followed no further. */ export declare let graphOf: (roots: Node[], specs: (node: Node) => Promise<string[]>, resolve: (from: Node, spec: string) => Node | undefined) => Promise<{
80
+ edges: Edges;
81
+ specs: Record<Node, string[]>;
82
+ }>;
83
+ /** Whether a node is one of the app's own files. */ export declare let own: (node: Node) => boolean;
84
+ /**
85
+ * How a graph of an app's scripts and package modules resolves: from an app
86
+ * script (`./<path>`), a relative specifier names the app's file at that
87
+ * path exactly, as a runtime links it, when `files` holds it; from a package
88
+ * module, a relative specifier is the address it makes. A bare one is what
89
+ * `imports` names for it, from either.
90
+ *
91
+ * ```ts
92
+ * import { assertEquals } from '@std/assert'
93
+ * let resolve = resolver(new Set(['a/b.ts', 'c.ts']), {
94
+ * p: 'https://y/__m/p.js',
95
+ * })
96
+ * assertEquals(resolve('./a/b.ts', '../c.ts'), './c.ts')
97
+ * assertEquals(resolve('./a/b.ts', './nope.ts'), undefined)
98
+ * assertEquals(resolve('./a/b.ts', 'p'), 'https://y/__m/p.js')
99
+ * assertEquals(resolve('https://y/__m/p.js', './q.js'), 'https://y/__m/q.js')
100
+ * assertEquals(resolve('/__m/p.js', './q.js'), '/__m/q.js')
101
+ * assertEquals(resolve('./c.ts', 'cloudflare:workers'), undefined)
102
+ * ```
103
+ */ export declare let resolver: (files: ReadonlySet<string>, imports: Readonly<Record<string, string>>) => any;
104
+ /** `to` as a relative specifier from `from`, both paths from one root.
105
+ *
106
+ * ```ts
107
+ * import { assertEquals } from '@std/assert'
108
+ * assertEquals(relativeTo('a/b.ts', 'a/c.ts'), './c.ts')
109
+ * assertEquals(relativeTo('a/b/c.ts', '__m/x.js'), '../../__m/x.js')
110
+ * assertEquals(relativeTo('w.ts', '__m/x.js'), './__m/x.js')
111
+ * ```
112
+ */ export declare let relativeTo: (from: string, to: string) => string;
113
+ /** Each of `nodes` written with its edges' addresses, as `address` names a
114
+ * module to the module importing it. Six read at once. */ export declare let linkedTexts: (nodes: Node[], edges: Edges, read: (node: Node) => Promise<string>, address: (from: Node, to: Node) => string) => Promise<Map<Node, string>>;
115
+ /** How a release's module workers were linked, carried to the next release
116
+ * so it reads only what changed. */ export type Linking = {
117
+ /** Each worker's entry, by its path from the app's root, and the linked
118
+ * module that is the worker. */ workers: Record<string, string>;
119
+ /** What each script starts as a worker, by `./<path>`, for those that
120
+ * start any. */ starts: Record<string, string[]>;
121
+ /** Each module a worker reaches, by node, and its specifiers. */ specs: Record<Node, string[]>;
122
+ /** Each linked module's name, by node. */ linked: Record<Node, string>;
123
+ };
124
+ /** A release's scripts as `linkWorkers` reads them. */ export type Release = {
125
+ /** Each script by its path from the app's root, and its compiled module's
126
+ * name (./file.ts). */ modules: Readonly<Record<string, string>>;
127
+ /** What its pages' map names for bare specifiers. */ imports: Readonly<Record<string, string>>;
128
+ linking?: Linking;
129
+ };
130
+ /**
131
+ * Each module worker a release's scripts start
132
+ * (`new Worker(new URL('./grow.ts', import.meta.url))`), linked: no import
133
+ * map reaches a worker, so every module it reaches is kept again with each
134
+ * specifier written as the address the page's map would resolve it to, an
135
+ * app's script at its own path with `?v=` naming its linked module, a
136
+ * package module at its own address. So a worker imports what its page
137
+ * can.
138
+ *
139
+ * What the release before (`previous`) linked is taken at its word: a
140
+ * script whose module is the same starts and imports what it did, a package
141
+ * module imports what it did, and a linked module it kept is not kept again.
142
+ * Only the rest is read (`source`, a script's own text; `read`, a module's
143
+ * compiled text by node), and only what nobody kept is written to `keep`,
144
+ * which says where a node's linked module is kept: an app's apart from a
145
+ * package's.
146
+ */ export declare let linkWorkers: (release: Release, {}: {
147
+ source: (path: string) => Promise<string>;
148
+ read: (node: Node, name: string) => Promise<string>;
149
+ keep: (node: Node) => Keep;
150
+ previous?: Release | null;
151
+ }) => Promise<Linking>;
152
+ /** `code` with each `import.meta.url` written as `url`: where a runtime
153
+ * gives a module no address of its own (a Worker's upload), a package module
154
+ * still finds the files beside it where it is served.
155
+ *
156
+ * ```ts
157
+ * import { assertEquals } from '@std/assert'
158
+ * assertEquals(
159
+ * located("let u = new URL('./x.css', import.meta.url), m = import.meta", 'https://y/__m/a.js'),
160
+ * "let u = new URL('./x.css', \"https://y/__m/a.js\"), m = import.meta",
161
+ * )
162
+ * ```
163
+ */ export declare let located: (code: string, url: string) => string;
164
+ /** Where a Worker's upload keeps a package module: under one folder, by its
165
+ * file's name, so its imports of its own package's modules resolve as
166
+ * written. */ export declare let UPLOADED: string;
167
+ /** A Worker's upload: each module by its name, as JavaScript, and each file
168
+ * a module imports as it is (`.wasm`, `.txt`) by its path, to read raw. */ export type Upload = {
169
+ modules: {
170
+ name: string;
171
+ code: string;
172
+ }[];
173
+ carry: string[];
174
+ };
175
+ /**
176
+ * The modules a Worker's server source (`main`, a path from the app's root)
177
+ * reaches, compiled one file at a time and linked by name (T-5555): an app's
178
+ * script under its own path, a package module under `UPLOADED`, every
179
+ * specifier written as the name it links to, since an upload has no map.
180
+ * `files` is every file the app holds; `read` is a module's compiled text,
181
+ * by node and name, as `linkWorkers` reads it, and `source` a file's own
182
+ * text, for a JSON or text file a module imports with its type, which uploads
183
+ * as a module of its value.
184
+ *
185
+ * Undefined when nothing reached is TypeScript or JSX and no package is
186
+ * imported: the source uploads as written. Null when the compiler must build
187
+ * it: an import with a type other than `json` or `text`, or a static import
188
+ * of a bare specifier neither the map nor the runtime (`node:`,
189
+ * `cloudflare:`) names. A dynamic one is left as written, failing only if it
190
+ * runs, as it would in a page.
191
+ */ export declare let serverUpload: (main: string, release: Release, files: ReadonlySet<string>, read: (node: Node, name: string) => Promise<string>, source: (path: string) => Promise<string>) => Promise<Upload | null | undefined>;
192
+ //# sourceMappingURL=link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.d.ts","sources":["../link.ts"],"names":[],"mappings":"AAYA,cAAc,IAAI,oBAAmB;AAGrC;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