@tinkerlandai/indiana-iam 0.2.0 → 0.3.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/README.md +74 -5
- package/assets/viewer.js +55 -2
- package/package.json +2 -1
- package/src/analyze.mjs +106 -22
- package/src/anchors.mjs +5 -0
- package/src/build-options.d.ts +5 -0
- package/src/build.mjs +10 -4
- package/src/cli.mjs +10 -4
- package/src/dom-payload-browser.mjs +28 -0
- package/src/dom-payload-json.mjs +12 -0
- package/src/dom-payload.mjs +50 -0
- package/src/framework-routes.mjs +41 -88
- package/src/generate.mjs +17 -6
- package/src/index.d.ts +11 -1
- package/src/index.mjs +1 -1
- package/src/integrity.mjs +4 -2
- package/src/library-entry.mjs +1 -0
- package/src/next.mjs +4 -3
- package/src/node-hashes.mjs +5 -2
- package/src/render-index.mjs +6 -4
- package/src/routing.mjs +1 -1
- package/src/schema-definition.mjs +8 -1
- package/src/source-entry.mjs +50 -0
- package/src/source-resolution.mjs +268 -0
- package/src/tanstack-routes.mjs +143 -0
- package/src/transform.mjs +2 -2
- package/src/upload.mjs +28 -6
- package/src/validate.mjs +14 -4
- package/src/vite.d.ts +4 -1
- package/src/vite.mjs +25 -10
package/src/vite.mjs
CHANGED
|
@@ -13,12 +13,13 @@ import { releasePath } from "./release-metadata.mjs";
|
|
|
13
13
|
* IAM as the current version. Server builds are skipped.
|
|
14
14
|
*/
|
|
15
15
|
export function indianaIam(options = {}) {
|
|
16
|
-
const { enabled = true, name, automaticAnchors = true, strict = false, rootFont, omitSvgResources, logger = console, apiKey, baseUrl, upload, fetch } = options;
|
|
16
|
+
const { enabled = true, name, entry, automaticAnchors = true, strict = false, rootFont, omitSvgResources, logger = console, apiKey, baseUrl, upload, client, fetch } = options;
|
|
17
17
|
let releaseId = null,
|
|
18
18
|
root,
|
|
19
19
|
outDir,
|
|
20
20
|
base,
|
|
21
|
-
server = false
|
|
21
|
+
server = false,
|
|
22
|
+
buildFailed = false;
|
|
22
23
|
return {
|
|
23
24
|
name: "indiana-iam",
|
|
24
25
|
apply: "build",
|
|
@@ -26,7 +27,7 @@ export function indianaIam(options = {}) {
|
|
|
26
27
|
async config(config) {
|
|
27
28
|
if (!enabled || config.build?.ssr) return;
|
|
28
29
|
root = await fs.realpath(path.resolve(config.root ?? process.cwd()));
|
|
29
|
-
const prepared = await prepareBuildRelease({ root, name, automaticAnchors, strict, logger });
|
|
30
|
+
const prepared = await prepareBuildRelease({ root, name, entry, automaticAnchors, strict, logger });
|
|
30
31
|
if (!prepared) return;
|
|
31
32
|
releaseId = prepared.releaseId;
|
|
32
33
|
return { define: { "import.meta.env.INDIANA_IAM_RELEASE_URL": JSON.stringify(releasePath(releaseId)) } };
|
|
@@ -37,26 +38,40 @@ export function indianaIam(options = {}) {
|
|
|
37
38
|
base = /^\/(?:[^/]+\/)*$/.test(config.base) ? config.base : "/";
|
|
38
39
|
server = Boolean(config.build.ssr);
|
|
39
40
|
},
|
|
40
|
-
transform
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
transform: {
|
|
42
|
+
// TanStack also runs a pre-transform. Anchor the original JSX before its
|
|
43
|
+
// reference/virtual module split, using the same original source path.
|
|
44
|
+
order: "pre",
|
|
45
|
+
handler(code, id) {
|
|
46
|
+
if (!enabled || server || !automaticAnchors || !releaseId || !root || id.startsWith("\0")) return null;
|
|
47
|
+
const [sourceId, query] = id.split("?");
|
|
48
|
+
if (query !== undefined) {
|
|
49
|
+
const parameters = [...new URLSearchParams(query)];
|
|
50
|
+
if (id.split("?").length !== 2 || parameters.length !== 1 || !["tsr-split", "tsr-shared"].includes(parameters[0][0]) || !parameters[0][1] || parameters[0][1].length > 256) return null;
|
|
51
|
+
}
|
|
52
|
+
const file = path.relative(root, sourceId).split(path.sep).join("/");
|
|
53
|
+
if (file.startsWith("../") || path.isAbsolute(file)) return null;
|
|
54
|
+
return transformSourceForIam(code, file);
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
buildEnd(error) {
|
|
58
|
+
if (error) buildFailed = true;
|
|
45
59
|
},
|
|
46
60
|
async closeBundle() {
|
|
47
61
|
const environment = this?.environment?.name;
|
|
48
|
-
if (!releaseId || server || (environment && environment !== "client")) return;
|
|
62
|
+
if (!releaseId || server || buildFailed || (environment && environment !== "client")) return;
|
|
49
63
|
await finishBuildRelease({
|
|
50
64
|
root,
|
|
51
65
|
releaseId,
|
|
52
66
|
name,
|
|
67
|
+
entry,
|
|
53
68
|
automaticAnchors,
|
|
54
69
|
cssDirectory: outDir,
|
|
55
70
|
mounts: [{ directory: outDir, urlPath: base }],
|
|
56
71
|
publicDirectory: outDir,
|
|
57
72
|
rootFont,
|
|
58
73
|
omitSvgResources,
|
|
59
|
-
upload: { apiKey, baseUrl, upload, fetch },
|
|
74
|
+
upload: { apiKey, baseUrl, upload, client, fetch },
|
|
60
75
|
strict,
|
|
61
76
|
logger,
|
|
62
77
|
});
|