fundus 0.25.0 → 0.26.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 +21 -0
- package/build/client/_app/immutable/chunks/B_4qwt4o.js +1 -0
- package/build/client/_app/immutable/chunks/B_4qwt4o.js.br +0 -0
- package/build/client/_app/immutable/chunks/B_4qwt4o.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{C4w39LtR.js → DS1jTxvm.js} +1 -1
- package/build/client/_app/immutable/chunks/DS1jTxvm.js.br +2 -0
- package/build/client/_app/immutable/chunks/DS1jTxvm.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{WV4B0d_0.js → p2q3f3Ml.js} +1 -1
- package/build/client/_app/immutable/chunks/p2q3f3Ml.js.br +0 -0
- package/build/client/_app/immutable/chunks/p2q3f3Ml.js.gz +0 -0
- package/build/client/_app/immutable/entry/{app.GgnXYpzJ.js → app.DgW6Eg19.js} +2 -2
- package/build/client/_app/immutable/entry/app.DgW6Eg19.js.br +0 -0
- package/build/client/_app/immutable/entry/app.DgW6Eg19.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.D3J5OM6w.js +1 -0
- package/build/client/_app/immutable/entry/start.D3J5OM6w.js.br +1 -0
- package/build/client/_app/immutable/entry/start.D3J5OM6w.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{0.D1g1plhI.js → 0.DdcKoZu5.js} +1 -1
- package/build/client/_app/immutable/nodes/0.DdcKoZu5.js.br +0 -0
- package/build/client/_app/immutable/nodes/0.DdcKoZu5.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{1.DzAnL2O6.js → 1.CoM7ng4c.js} +1 -1
- package/build/client/_app/immutable/nodes/1.CoM7ng4c.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.CoM7ng4c.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{2.BMN1YTJ4.js → 2.CV-vWxFI.js} +1 -1
- package/build/client/_app/immutable/nodes/2.CV-vWxFI.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.CV-vWxFI.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{3.DL_TiE5x.js → 3.B9mDsYGS.js} +1 -1
- package/build/client/_app/immutable/nodes/3.B9mDsYGS.js.br +0 -0
- package/build/client/_app/immutable/nodes/3.B9mDsYGS.js.gz +0 -0
- package/build/client/_app/immutable/nodes/{4.D7FHmbgq.js → 4.CFfIs-6D.js} +1 -1
- package/build/client/_app/immutable/nodes/4.CFfIs-6D.js.br +0 -0
- package/build/client/_app/immutable/nodes/4.CFfIs-6D.js.gz +0 -0
- package/build/client/_app/version.json +1 -1
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/handler.js +7 -7
- package/build/index.js +7 -7
- package/build/server/chunks/chunks/{context.js-4TO_atTF.js → context.js-mE8mFnsg.js} +45 -12
- package/build/server/chunks/chunks/context.js-mE8mFnsg.js.map +1 -0
- package/build/server/chunks/chunks/{exports.js-BAfR8rsb.js → exports.js-CDl9URFG.js} +2 -2
- package/build/server/chunks/chunks/{exports.js-BAfR8rsb.js.map → exports.js-CDl9URFG.js.map} +1 -1
- package/build/server/chunks/chunks/{internal.js-B3hOADoz.js → internal.js-Bz3sw0lq.js} +3 -3
- package/build/server/chunks/chunks/{internal.js-B3hOADoz.js.map → internal.js-Bz3sw0lq.js.map} +1 -1
- package/build/server/chunks/chunks/internal2.js-BlXt2rfE.js.map +1 -1
- package/build/server/chunks/chunks/{shared.js-DN477dAr.js → shared.js-DwJl8ZNw.js} +2 -2
- package/build/server/chunks/chunks/{shared.js-DN477dAr.js.map → shared.js-DwJl8ZNw.js.map} +1 -1
- package/build/server/chunks/chunks/{utils.js-zf3Q16Eh.js → utils.js-DoU5Jolh.js} +3 -3
- package/build/server/chunks/chunks/{utils.js-zf3Q16Eh.js.map → utils.js-DoU5Jolh.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/assets/_id_/{_server.ts.js-Aa7zYzUB.js → _server.ts.js-CM6PedpD.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/assets/_id_/{_server.ts.js-Aa7zYzUB.js.map → _server.ts.js-CM6PedpD.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/assets/_id_/raw/{_server.ts.js-CM73kt1H.js → _server.ts.js-BpfOlmKN.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/assets/_id_/raw/{_server.ts.js-CM73kt1H.js.map → _server.ts.js-BpfOlmKN.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/assets/_id_/reimport/{_server.ts.js-CyiEsjc3.js → _server.ts.js-UvDSeD5O.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/assets/_id_/reimport/{_server.ts.js-CyiEsjc3.js.map → _server.ts.js-UvDSeD5O.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/assets/_id_/retag/{_server.ts.js-Cpt_vVY0.js → _server.ts.js-D4kq3W1-.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/assets/_id_/retag/{_server.ts.js-Cpt_vVY0.js.map → _server.ts.js-D4kq3W1-.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/assets/{_server.ts.js-BVdeCRy0.js → _server.ts.js-CcV2BTCH.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/assets/{_server.ts.js-BVdeCRy0.js.map → _server.ts.js-CcV2BTCH.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/assets/delete/{_server.ts.js-QEa0nYZE.js → _server.ts.js-Cb0Dn_a2.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/assets/delete/{_server.ts.js-QEa0nYZE.js.map → _server.ts.js-Cb0Dn_a2.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/assets/move/{_server.ts.js-Dk0sFdoM.js → _server.ts.js-ChlfFRqR.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/assets/move/{_server.ts.js-Dk0sFdoM.js.map → _server.ts.js-ChlfFRqR.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/events/{_server.ts.js-CO8RZm3e.js → _server.ts.js-DnrgWGff.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/events/{_server.ts.js-CO8RZm3e.js.map → _server.ts.js-DnrgWGff.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/folders/_path_/{_server.ts.js-8RzyUK6g.js → _server.ts.js-CFM83bne.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/folders/_path_/{_server.ts.js-8RzyUK6g.js.map → _server.ts.js-CFM83bne.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/folders/{_server.ts.js-YWliM590.js → _server.ts.js-BtJIovEG.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/folders/{_server.ts.js-YWliM590.js.map → _server.ts.js-BtJIovEG.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/imports/{_server.ts.js-CeXmOrwN.js → _server.ts.js-BAHE77r2.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/imports/{_server.ts.js-CeXmOrwN.js.map → _server.ts.js-BAHE77r2.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/manifests/_name_/{_server.ts.js-DQaLSdGl.js → _server.ts.js-Cypw-CjT.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/manifests/_name_/{_server.ts.js-DQaLSdGl.js.map → _server.ts.js-Cypw-CjT.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/manifests/{_server.ts.js-BE_nYFP_.js → _server.ts.js-FrntF4Gn.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/manifests/{_server.ts.js-BE_nYFP_.js.map → _server.ts.js-FrntF4Gn.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/raw/adopt/{_server.ts.js-BGxvZ4EV.js → _server.ts.js-BeEHDBep.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/raw/adopt/{_server.ts.js-BGxvZ4EV.js.map → _server.ts.js-BeEHDBep.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/raw/edited/accept/{_server.ts.js-Cvwr9a0l.js → _server.ts.js-Di1kfrl2.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/raw/edited/accept/{_server.ts.js-Cvwr9a0l.js.map → _server.ts.js-Di1kfrl2.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/raw/edited/dismiss/{_server.ts.js-DEMDXHsR.js → _server.ts.js-CrLHlnap.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/raw/edited/dismiss/{_server.ts.js-DEMDXHsR.js.map → _server.ts.js-CrLHlnap.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/reconcile/{_server.ts.js-DoeEIUoG.js → _server.ts.js-BcqKQTDk.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/reconcile/{_server.ts.js-DoeEIUoG.js.map → _server.ts.js-BcqKQTDk.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/reveal/{_server.ts.js-0hMtYoB1.js → _server.ts.js-oFUf-T_H.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/reveal/{_server.ts.js-0hMtYoB1.js.map → _server.ts.js-oFUf-T_H.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/state/{_server.ts.js-B4YWmlkC.js → _server.ts.js-D46dsJCB.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/state/{_server.ts.js-B4YWmlkC.js.map → _server.ts.js-D46dsJCB.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/api/usage/{_server.ts.js-dNLtLO2U.js → _server.ts.js-BlKjsU-v.js} +2 -2
- package/build/server/chunks/entries/endpoints/api/usage/{_server.ts.js-dNLtLO2U.js.map → _server.ts.js-BlKjsU-v.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/files/proxy/_...path_/{_server.ts.js-BtCkf-hk.js → _server.ts.js-DafDgMis.js} +2 -2
- package/build/server/chunks/entries/endpoints/files/proxy/_...path_/{_server.ts.js-BtCkf-hk.js.map → _server.ts.js-DafDgMis.js.map} +1 -1
- package/build/server/chunks/entries/endpoints/files/raw/_...path_/{_server.ts.js-CozrPtRv.js → _server.ts.js-6Vn2UuF6.js} +2 -2
- package/build/server/chunks/entries/endpoints/files/raw/_...path_/{_server.ts.js-CozrPtRv.js.map → _server.ts.js-6Vn2UuF6.js.map} +1 -1
- package/build/server/chunks/entries/{hooks.server.js-Cnsi5KsE.js → hooks.server.js-CSypLuCa.js} +2 -2
- package/build/server/chunks/entries/{hooks.server.js-Cnsi5KsE.js.map → hooks.server.js-CSypLuCa.js.map} +1 -1
- package/build/server/chunks/{handler-BN27c-Da.js → handler-C0NXVVDu.js} +5 -5
- package/build/server/chunks/{handler-BN27c-Da.js.map → handler-C0NXVVDu.js.map} +1 -1
- package/build/server/chunks/{index.js-C1f-Qrf0.js → index.js-D3rzqgKi.js} +5 -5
- package/build/server/chunks/{index.js-C1f-Qrf0.js.map → index.js-D3rzqgKi.js.map} +1 -1
- package/build/server/chunks/{manifest.js-CFkuYTzu.js → manifest.js-Dw3Fvt_0.js} +29 -29
- package/build/server/chunks/{manifest.js-CFkuYTzu.js.map → manifest.js-Dw3Fvt_0.js.map} +1 -1
- package/build/server/chunks/nodes/{0.js-B1i6yC_e.js → 0.js-D1uRRjFL.js} +2 -2
- package/build/server/chunks/nodes/{0.js-B1i6yC_e.js.map → 0.js-D1uRRjFL.js.map} +1 -1
- package/build/server/chunks/nodes/1.js-sYnc9kZu.js +7 -0
- package/build/server/chunks/nodes/{1.js-Bv64OO0t.js.map → 1.js-sYnc9kZu.js.map} +1 -1
- package/build/server/chunks/nodes/{2.js-DivaYfS1.js → 2.js-B3OCWo8p.js} +2 -2
- package/build/server/chunks/nodes/{2.js-DivaYfS1.js.map → 2.js-B3OCWo8p.js.map} +1 -1
- package/build/server/chunks/nodes/3.js-BWkr9ibc.js +7 -0
- package/build/server/chunks/nodes/{3.js-CUAbHOxb.js.map → 3.js-BWkr9ibc.js.map} +1 -1
- package/build/server/chunks/nodes/{4.js-Ceg0ylPI.js → 4.js-gujLHNff.js} +2 -2
- package/build/server/chunks/nodes/{4.js-Ceg0ylPI.js.map → 4.js-gujLHNff.js.map} +1 -1
- package/dist/cli.js +9 -0
- package/dist/core/figma-tag-script.d.ts +141 -0
- package/dist/core/figma-tag-script.js +236 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +1 -0
- package/dist/server/cli-commands.d.ts +6 -0
- package/dist/server/cli-commands.js +1 -1
- package/dist/server/cli-figma-tags.d.ts +2 -0
- package/dist/server/cli-figma-tags.js +222 -0
- package/dist/server/figma-tags.d.ts +61 -0
- package/dist/server/figma-tags.js +153 -0
- package/dist/server/importers/figma.d.ts +17 -0
- package/dist/server/importers/figma.js +43 -18
- package/package.json +1 -1
- package/build/client/_app/immutable/chunks/C4w39LtR.js.br +0 -1
- package/build/client/_app/immutable/chunks/C4w39LtR.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DGy-bMvO.js +0 -1
- package/build/client/_app/immutable/chunks/DGy-bMvO.js.br +0 -0
- package/build/client/_app/immutable/chunks/DGy-bMvO.js.gz +0 -0
- package/build/client/_app/immutable/chunks/WV4B0d_0.js.br +0 -0
- package/build/client/_app/immutable/chunks/WV4B0d_0.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.GgnXYpzJ.js.br +0 -0
- package/build/client/_app/immutable/entry/app.GgnXYpzJ.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.O9RwuDjf.js +0 -1
- package/build/client/_app/immutable/entry/start.O9RwuDjf.js.br +0 -0
- package/build/client/_app/immutable/entry/start.O9RwuDjf.js.gz +0 -0
- package/build/client/_app/immutable/nodes/0.D1g1plhI.js.br +0 -0
- package/build/client/_app/immutable/nodes/0.D1g1plhI.js.gz +0 -0
- package/build/client/_app/immutable/nodes/1.DzAnL2O6.js.br +0 -2
- package/build/client/_app/immutable/nodes/1.DzAnL2O6.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.BMN1YTJ4.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.BMN1YTJ4.js.gz +0 -0
- package/build/client/_app/immutable/nodes/3.DL_TiE5x.js.br +0 -0
- package/build/client/_app/immutable/nodes/3.DL_TiE5x.js.gz +0 -0
- package/build/client/_app/immutable/nodes/4.D7FHmbgq.js.br +0 -0
- package/build/client/_app/immutable/nodes/4.D7FHmbgq.js.gz +0 -0
- package/build/server/chunks/chunks/context.js-4TO_atTF.js.map +0 -1
- package/build/server/chunks/nodes/1.js-Bv64OO0t.js +0 -7
- package/build/server/chunks/nodes/3.js-CUAbHOxb.js +0 -7
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planning for the `fundus figma prepare-*-tag` commands. The Figma REST API
|
|
3
|
+
* can read shared plugin data but not write it, so Fundus validates against a
|
|
4
|
+
* REST snapshot of the file plus the local library, then hands back a
|
|
5
|
+
* `use_figma` script (figma-tag-script.ts) that performs the write inside
|
|
6
|
+
* Figma and re-checks the live document first.
|
|
7
|
+
*/
|
|
8
|
+
import { assetIdError, buildDeleteTagScript, buildSetTagScript } from '../core/index.js';
|
|
9
|
+
import { fetchFigmaDocument, figmaDocumentNodes, validateFigmaSourceParameters } from './importers/figma.js';
|
|
10
|
+
import { LibraryStore } from './library-store.js';
|
|
11
|
+
/** An expected refusal that carries the file's current tags so the caller can pick another. */
|
|
12
|
+
export class FigmaTagConflictError extends Error {
|
|
13
|
+
existingTags;
|
|
14
|
+
constructor(message, existingTags) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.existingTags = existingTags;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Normalize a `12:34` / `12-34` node id; Fundus imports only this id form. */
|
|
20
|
+
export function parseFigmaNodeId(value) {
|
|
21
|
+
if (!/^\d+[-:]\d+$/.test(value)) {
|
|
22
|
+
throw new Error(`"${value}" is not a taggable Figma node id — use the form 12:34 (or 12-34 as in a node-id link parameter). Nodes inside instances (ids starting with "I") inherit their tag from the main component; tag the node there.`);
|
|
23
|
+
}
|
|
24
|
+
return value.replace('-', ':');
|
|
25
|
+
}
|
|
26
|
+
function tagListing(nodes) {
|
|
27
|
+
return nodes
|
|
28
|
+
.filter((node) => node.tag !== null)
|
|
29
|
+
.map((node) => ({
|
|
30
|
+
tag: node.tag,
|
|
31
|
+
nodeId: node.nodeId,
|
|
32
|
+
nodeName: node.nodeName,
|
|
33
|
+
page: node.page
|
|
34
|
+
}))
|
|
35
|
+
.sort((a, b) => a.tag.localeCompare(b.tag));
|
|
36
|
+
}
|
|
37
|
+
function describeNode(node) {
|
|
38
|
+
return `"${node.nodeName}" (${node.nodeId}) on page "${node.page}"`;
|
|
39
|
+
}
|
|
40
|
+
/** The library asset imported from `tag` in `fileKey`, if any. */
|
|
41
|
+
function tagImportedAsset(library, fileKey, tag) {
|
|
42
|
+
const record = library.assets[tag];
|
|
43
|
+
if (record?.importSource?.importer !== 'figma')
|
|
44
|
+
return null;
|
|
45
|
+
const source = validateFigmaSourceParameters(record.importSource.parameters);
|
|
46
|
+
return source.mode === 'tag' && source.fundusTag === tag && source.fileKey === fileKey
|
|
47
|
+
? tag
|
|
48
|
+
: null;
|
|
49
|
+
}
|
|
50
|
+
export function planSetFigmaTag(request, { library, document }) {
|
|
51
|
+
const { fileKey, nodeId, tag, force } = request;
|
|
52
|
+
const problem = assetIdError(tag);
|
|
53
|
+
if (problem)
|
|
54
|
+
throw new Error(problem);
|
|
55
|
+
const nodes = figmaDocumentNodes(document);
|
|
56
|
+
const existingTags = tagListing(nodes);
|
|
57
|
+
const warnings = [];
|
|
58
|
+
const holder = nodes.find((node) => node.tag === tag && node.nodeId !== nodeId);
|
|
59
|
+
if (holder) {
|
|
60
|
+
throw new FigmaTagConflictError(`Tag "${tag}" is already used by ${describeNode(holder)} — choose another tag (existing tags are listed).`, existingTags);
|
|
61
|
+
}
|
|
62
|
+
if (Object.hasOwn(library.assets, tag) && tagImportedAsset(library, fileKey, tag) === null) {
|
|
63
|
+
throw new FigmaTagConflictError(`A Fundus asset "${tag}" already exists and is not imported from this tag in file "${fileKey}" — \`fundus asset ingest --figma-tag ${tag}\` would collide; choose another tag.`, existingTags);
|
|
64
|
+
}
|
|
65
|
+
const node = nodes.find((candidate) => candidate.nodeId === nodeId) ?? null;
|
|
66
|
+
if (!node) {
|
|
67
|
+
warnings.push(`Node ${nodeId} is not in the Figma REST snapshot yet (new or unsynced node); the script verifies it exists before writing.`);
|
|
68
|
+
}
|
|
69
|
+
const previousTag = node?.tag ?? null;
|
|
70
|
+
if (previousTag === tag) {
|
|
71
|
+
if (!force) {
|
|
72
|
+
throw new Error(`Node ${describeNode(node)} already carries tag "${tag}" — nothing to do. Pass --force to regenerate the script anyway (e.g. to repair its annotation).`);
|
|
73
|
+
}
|
|
74
|
+
warnings.push(`Node ${nodeId} already carries tag "${tag}"; the script rewrites it.`);
|
|
75
|
+
}
|
|
76
|
+
else if (previousTag !== null) {
|
|
77
|
+
const orphaned = tagImportedAsset(library, fileKey, previousTag);
|
|
78
|
+
const followUp = orphaned
|
|
79
|
+
? ` Fundus asset "${orphaned}" is imported from that tag — afterwards run \`fundus asset reimport ${orphaned} --figma-tag ${tag}\` (renames it to "${tag}").`
|
|
80
|
+
: '';
|
|
81
|
+
if (!force) {
|
|
82
|
+
throw new Error(`Node ${describeNode(node)} already carries tag "${previousTag}". Pass --force to replace it.${followUp}`);
|
|
83
|
+
}
|
|
84
|
+
warnings.push(`Replaces tag "${previousTag}" on node ${nodeId}.${followUp}`);
|
|
85
|
+
}
|
|
86
|
+
if (tagImportedAsset(library, fileKey, tag) !== null && !nodes.some((n) => n.tag === tag)) {
|
|
87
|
+
warnings.push(`Fundus asset "${tag}" is imported from this tag; its next \`fundus asset reimport ${tag}\` resolves to this node.`);
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
fileKey,
|
|
91
|
+
nodeId,
|
|
92
|
+
tag,
|
|
93
|
+
previousTag,
|
|
94
|
+
warnings,
|
|
95
|
+
code: buildSetTagScript({ nodeId, tag, force })
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export function planDeleteFigmaTag(request, { library, document }) {
|
|
99
|
+
const { fileKey, force } = request;
|
|
100
|
+
if (request.tag !== undefined) {
|
|
101
|
+
const problem = assetIdError(request.tag);
|
|
102
|
+
if (problem)
|
|
103
|
+
throw new Error(problem);
|
|
104
|
+
}
|
|
105
|
+
const nodes = figmaDocumentNodes(document);
|
|
106
|
+
const existingTags = tagListing(nodes);
|
|
107
|
+
let node;
|
|
108
|
+
if (request.nodeId !== undefined) {
|
|
109
|
+
const found = nodes.find((candidate) => candidate.nodeId === request.nodeId);
|
|
110
|
+
if (!found) {
|
|
111
|
+
throw new Error(`Node ${request.nodeId} is not in Figma file "${fileKey}".`);
|
|
112
|
+
}
|
|
113
|
+
if (found.tag === null) {
|
|
114
|
+
throw new FigmaTagConflictError(`Node ${describeNode(found)} carries no Fundus tag (existing tags are listed).`, existingTags);
|
|
115
|
+
}
|
|
116
|
+
if (request.tag !== undefined && found.tag !== request.tag) {
|
|
117
|
+
throw new FigmaTagConflictError(`Node ${describeNode(found)} carries tag "${found.tag}", not "${request.tag}".`, existingTags);
|
|
118
|
+
}
|
|
119
|
+
node = found;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
const matches = nodes.filter((candidate) => candidate.tag === request.tag);
|
|
123
|
+
if (matches.length === 0) {
|
|
124
|
+
throw new FigmaTagConflictError(`No node carries tag "${request.tag}" in Figma file "${fileKey}" (existing tags are listed).`, existingTags);
|
|
125
|
+
}
|
|
126
|
+
if (matches.length > 1) {
|
|
127
|
+
throw new FigmaTagConflictError(`Tag "${request.tag}" is on ${matches.length} nodes (${matches.map((match) => match.nodeId).join(', ')}) — pass --node-id to pick one.`, existingTags);
|
|
128
|
+
}
|
|
129
|
+
node = matches[0];
|
|
130
|
+
}
|
|
131
|
+
const tag = node.tag;
|
|
132
|
+
const warnings = [];
|
|
133
|
+
const imported = tagImportedAsset(library, fileKey, tag);
|
|
134
|
+
if (imported) {
|
|
135
|
+
const consequence = `Fundus asset "${imported}" is imported from this tag; without it, \`fundus asset reimport ${imported}\` fails until the tag is set again.`;
|
|
136
|
+
if (!force)
|
|
137
|
+
throw new Error(`${consequence} Pass --force to delete the tag anyway.`);
|
|
138
|
+
warnings.push(consequence);
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
fileKey,
|
|
142
|
+
nodeId: node.nodeId,
|
|
143
|
+
tag,
|
|
144
|
+
warnings,
|
|
145
|
+
code: buildDeleteTagScript({ nodeId: node.nodeId, tag })
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/** Load the library and the file's REST document for planning. */
|
|
149
|
+
export async function loadFigmaTagPlanContext(config, fileKey) {
|
|
150
|
+
const library = await new LibraryStore(config).read();
|
|
151
|
+
const document = await fetchFigmaDocument(fileKey, { config, fetch: globalThis.fetch });
|
|
152
|
+
return { library, document };
|
|
153
|
+
}
|
|
@@ -40,5 +40,22 @@ export declare function parseFigmaFileKey(value: string): string;
|
|
|
40
40
|
export declare function validateFigmaSourceParameters(value: unknown): FigmaSourceParameters;
|
|
41
41
|
export declare function resolveSafeDownloadTarget(value: string | URL): Promise<PinnedHttpsTarget>;
|
|
42
42
|
export declare function assertSafeDownloadUrl(value: string | URL): Promise<URL>;
|
|
43
|
+
/** One node in a Figma REST document tree, as the tag commands report it. */
|
|
44
|
+
export interface FigmaDocumentNode {
|
|
45
|
+
nodeId: string;
|
|
46
|
+
nodeName: string;
|
|
47
|
+
/** Name of the page (canvas) containing the node. */
|
|
48
|
+
page: string;
|
|
49
|
+
/** The node's Fundus tag, or null when untagged. */
|
|
50
|
+
tag: string | null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Every taggable node in a REST document tree (`plugin_data=shared`), in
|
|
54
|
+
* document order. Nodes inside instances are skipped: they echo the main
|
|
55
|
+
* component node's tag, and Fundus imports only plain `12:34` node ids.
|
|
56
|
+
*/
|
|
57
|
+
export declare function figmaDocumentNodes(document: unknown): FigmaDocumentNode[];
|
|
58
|
+
/** The whole document tree of a Figma file, including every node's shared plugin data. */
|
|
59
|
+
export declare function fetchFigmaDocument(fileKey: string, context: ImporterContext): Promise<unknown>;
|
|
43
60
|
export declare function resolveTagToNode(fileKey: string, tag: string, context: ImporterContext): Promise<string>;
|
|
44
61
|
export declare const figmaSourceImporter: ServerSourceImporter<FigmaImportInput, FigmaSourceParameters>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { lookup } from 'node:dns/promises';
|
|
2
2
|
import { isIP } from 'node:net';
|
|
3
3
|
import sharp from 'sharp';
|
|
4
|
-
import { isValidAssetId } from '../../core/index.js';
|
|
4
|
+
import { isInstanceSublayerId, isValidAssetId } from '../../core/index.js';
|
|
5
5
|
import { SourceImportError, invalidInput } from './contract.js';
|
|
6
6
|
import { requestPinnedHttps } from './pinned-https.js';
|
|
7
7
|
const MAX_DOWNLOAD_BYTES = 50 * 1024 * 1024;
|
|
@@ -383,21 +383,43 @@ async function validatePng(bytes) {
|
|
|
383
383
|
throw new SourceImportError('image-too-large', 'Figma export exceeds the 32 megapixel limit.');
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
386
|
+
/**
|
|
387
|
+
* Every taggable node in a REST document tree (`plugin_data=shared`), in
|
|
388
|
+
* document order. Nodes inside instances are skipped: they echo the main
|
|
389
|
+
* component node's tag, and Fundus imports only plain `12:34` node ids.
|
|
390
|
+
*/
|
|
391
|
+
export function figmaDocumentNodes(document) {
|
|
392
|
+
const nodes = [];
|
|
393
|
+
const visit = (value, page) => {
|
|
394
|
+
const current = record(value);
|
|
395
|
+
if (!current)
|
|
396
|
+
return;
|
|
397
|
+
const name = typeof current.name === 'string' ? current.name : '';
|
|
398
|
+
const pageName = current.type === 'CANVAS' ? name : page;
|
|
399
|
+
if (typeof current.id === 'string' &&
|
|
400
|
+
current.type !== 'DOCUMENT' &&
|
|
401
|
+
current.type !== 'CANVAS' &&
|
|
402
|
+
!isInstanceSublayerId(current.id)) {
|
|
403
|
+
const shared = record(current.sharedPluginData);
|
|
404
|
+
const fundus = shared ? record(shared.fundus) : null;
|
|
405
|
+
const tag = fundus && typeof fundus.assetId === 'string' ? fundus.assetId : '';
|
|
406
|
+
nodes.push({
|
|
407
|
+
nodeId: current.id,
|
|
408
|
+
nodeName: name,
|
|
409
|
+
page: pageName,
|
|
410
|
+
tag: tag === '' ? null : tag
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
if (Array.isArray(current.children)) {
|
|
414
|
+
for (const child of current.children)
|
|
415
|
+
visit(child, pageName);
|
|
416
|
+
}
|
|
417
|
+
};
|
|
418
|
+
visit(record(document), '');
|
|
419
|
+
return nodes;
|
|
399
420
|
}
|
|
400
|
-
|
|
421
|
+
/** The whole document tree of a Figma file, including every node's shared plugin data. */
|
|
422
|
+
export async function fetchFigmaDocument(fileKey, context) {
|
|
401
423
|
const token = context.config.import.figma.token;
|
|
402
424
|
if (!token) {
|
|
403
425
|
throw new SourceImportError('not-configured', 'Figma access is not configured.');
|
|
@@ -416,15 +438,18 @@ export async function resolveTagToNode(fileKey, tag, context) {
|
|
|
416
438
|
if (!body || body.err || (typeof body.status === 'number' && body.status >= 400)) {
|
|
417
439
|
throw new SourceImportError('invalid-response', 'Figma returned an invalid response.');
|
|
418
440
|
}
|
|
419
|
-
|
|
420
|
-
|
|
441
|
+
return body.document;
|
|
442
|
+
}
|
|
443
|
+
export async function resolveTagToNode(fileKey, tag, context) {
|
|
444
|
+
const document = await fetchFigmaDocument(fileKey, context);
|
|
445
|
+
const matches = figmaDocumentNodes(document).filter((node) => node.tag === tag);
|
|
421
446
|
if (matches.length === 0) {
|
|
422
447
|
throw new SourceImportError('not-found', `No Figma node is tagged "${tag}" in this file.`);
|
|
423
448
|
}
|
|
424
449
|
if (matches.length > 1) {
|
|
425
450
|
throw new SourceImportError('ambiguous-tag', `More than one Figma node is tagged "${tag}" in this file.`);
|
|
426
451
|
}
|
|
427
|
-
return matches[0];
|
|
452
|
+
return matches[0].nodeId;
|
|
428
453
|
}
|
|
429
454
|
async function materialize(source, context) {
|
|
430
455
|
const token = context.config.import.figma.token;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
I@dr]����2D�v��Q����.xh���@���!�UCiK~Gb�/��R�����,լ���[�x91���u15�n2 ��:�-�
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{H as e,U as t,V as n,it as r,nt as i,r as a,t as o,tt as s}from"./DLEDBLL1.js";var c=class{constructor(e,t){this.status=e,typeof t==`string`?this.body={message:t}:t?this.body=t:this.body={message:`Error: ${e}`}}toString(){return JSON.stringify(this.body)}},l=class{constructor(e,t){try{new Headers({location:t})}catch{throw Error(`Invalid redirect location ${JSON.stringify(t)}: this string contains characters that cannot be used in HTTP headers`)}this.status=e,this.location=t}},u=class extends Error{constructor(e,t,n){super(n),this.status=e,this.text=t}};new URL(`sveltekit-internal://`);function d(e,t){return e===`/`||t===`ignore`?e:t===`never`?e.endsWith(`/`)?e.slice(0,-1):e:t===`always`&&!e.endsWith(`/`)?e+`/`:e}function f(e){return e.split(`%25`).map(decodeURI).join(`%25`)}function p(e){for(let t in e)e[t]=decodeURIComponent(e[t]);return e}function m({href:e}){return e.split(`#`)[0]}function h(){}function ee(...e){let t=5381;for(let n of e)if(typeof n==`string`){let e=n.length;for(;e;)t=t*33^n.charCodeAt(--e)}else if(ArrayBuffer.isView(n)){let e=new Uint8Array(n.buffer,n.byteOffset,n.byteLength),r=e.length;for(;r;)t=t*33^e[--r]}else throw TypeError(`value must be a string or TypedArray`);return(t>>>0).toString(36)}new TextEncoder;function g(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}var _=window.fetch;window.fetch=(e,t)=>((e instanceof Request?e.method:t?.method||`GET`)!==`GET`&&v.delete(b(e)),_(e,t));var v=new Map;function te(e,t){let n=b(e,t),r=document.querySelector(n);if(r?.textContent){r.remove();let{body:e,...t}=JSON.parse(r.textContent);r.getAttribute(`data-b64`)!==null&&(e=g(e));let i=r.getAttribute(`data-ttl`);return i&&v.set(n,{body:e,init:t,ttl:1e3*Number(i)}),Promise.resolve(new Response(e,t))}return window.fetch(e,t)}function y(e,t,n){if(v.size>0){let t=b(e,n),r=v.get(t);if(r){if(performance.now()<r.ttl&&[`default`,`force-cache`,`only-if-cached`,void 0].includes(n?.cache))return new Response(r.body,r.init);v.delete(t)}}return window.fetch(t,n)}function b(e,t){let n=`script[data-sveltekit-fetched][data-url=${JSON.stringify(e instanceof Request?e.url:e)}]`;if(t?.headers||t?.body){let e=[];t.headers&&e.push([...new Headers(t.headers)].join(`,`)),t.body&&(typeof t.body==`string`||ArrayBuffer.isView(t.body))&&e.push(t.body),n+=`[data-hash="${ee(...e)}"]`}return n}var ne=/^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/,re=/^\/\((?:[^)]+)\)$/;function x(e){let t=[];return{pattern:e===`/`||re.test(e)?/^\/$/:RegExp(`^${ae(e).map(e=>{let n=/^\[\.\.\.(\w+)(?:=(\w+))?\]$/.exec(e);if(n)return t.push({name:n[1],matcher:n[2],optional:!1,rest:!0,chained:!0}),`(?:/([^]*))?`;let r=/^\[\[(\w+)(?:=(\w+))?\]\]$/.exec(e);if(r)return t.push({name:r[1],matcher:r[2],optional:!0,rest:!1,chained:!0}),`(?:/([^/]+))?`;if(!e)return;let i=e.split(/\[(.+?)\](?!\])/);return`/`+i.map((e,n)=>{if(n%2){if(e.startsWith(`x+`))return se(String.fromCharCode(parseInt(e.slice(2),16)));if(e.startsWith(`u+`))return se(String.fromCharCode(...e.slice(2).split(`-`).map(e=>parseInt(e,16))));let[,r,a,o,s]=ne.exec(e);return t.push({name:o,matcher:s,optional:!!r,rest:!!a,chained:a?n===1&&i[0]===``:!1}),a?`([^]*?)`:r?`([^/]*)?`:`([^/]+?)`}return se(e)}).join(``)}).join(``)}/?$`),params:t}}function ie(e){return e!==``&&!/^\([^)]+\)$/.test(e)}function ae(e){return e.slice(1).split(`/`).filter(ie)}function oe(e,t,n){let r={},i=e.slice(1),a=i.filter(e=>e!==void 0),o=0;for(let e=0;e<t.length;e+=1){let s=t[e],c=i[e-o];if(s.chained&&s.rest&&o&&(c=i.slice(e-o,e+1).filter(e=>e).join(`/`),o=0),c===void 0)if(s.rest)c=``;else continue;if(!s.matcher||n[s.matcher](c)){r[s.name]=c;let n=t[e+1],l=i[e+1];n&&!n.rest&&n.optional&&l&&s.chained&&(o=0),!n&&!l&&Object.keys(r).length===a.length&&(o=0);continue}if(s.optional&&s.chained){o++;continue}return}if(!o)return r}function se(e){return e.normalize().replace(/[[\]]/g,`\\$&`).replace(/%/g,`%25`).replace(/\//g,`%2[Ff]`).replace(/\?/g,`%3[Ff]`).replace(/#/g,`%23`).replace(/[.*+?^${}()|\\]/g,`\\$&`)}var ce=/\[(\[)?(\.\.\.)?(\w+?)(?:=(\w+))?\]\]?/g;function le(e,t){let n=ae(e),r=e!=`/`&&e.endsWith(`/`);return`/`+n.map(n=>n.replace(ce,(n,r,i,a)=>{let o=t[a];if(!o){if(r||i&&o!==void 0)return``;throw Error(`Missing parameter '${a}' in route ${e}`)}if(o.startsWith(`/`)||o.endsWith(`/`))throw Error(`Parameter '${a}' in route ${e} cannot start or end with a slash -- this would cause an invalid route like foo//bar`);return o})).filter(Boolean).join(`/`)+(r?`/`:``)}function ue({nodes:e,server_loads:t,dictionary:n,matchers:r}){let i=new Set(t);return Object.entries(n).map(([t,[n,i,s]])=>{let{pattern:c,params:l}=x(t),u={id:t,exec:e=>{let t=c.exec(e);if(t)return oe(t,l,r)},errors:[1,...s||[]].map(t=>e[t]),layouts:[0,...i||[]].map(o),leaf:a(n)};return u.errors.length=u.layouts.length=Math.max(u.errors.length,u.layouts.length),u});function a(t){let n=t<0;return n&&(t=~t),[n,e[t]]}function o(t){return t===void 0?t:[i.has(t),e[t]]}}function de(e,t=JSON.parse){try{return t(sessionStorage[e])}catch{}}function fe(e,t,n=JSON.stringify){let r=n(t);try{sessionStorage[e]=r}catch{}}var S=globalThis.__sveltekit_53zxyu?.base??``,pe=globalThis.__sveltekit_53zxyu?.assets??S??``,me=``;function he(...e){if(!e[0].startsWith(`/`))throw Error(`Cannot use \`resolve(...)\` with a non-absolute pathname or route ID (got "${e[0]}"). \`resolve\` is only for internal pathnames and route IDs; external URLs should be used directly.`);return S+me+le(e[0],e[1])}var ge=`1790323508030`,_e=`sveltekit:snapshot`,ve=`sveltekit:scroll`,ye=`sveltekit:states`,C=`sveltekit:history`,w=`sveltekit:navigation`,T={tap:1,hover:2,viewport:3,eager:4,off:-1,false:-1},E=location.origin;function be(e){if(e instanceof URL)return e;let t=document.baseURI;if(!t){let e=document.getElementsByTagName(`base`);t=e.length?e[0].href:document.URL}return new URL(e,t)}function D(){return{x:pageXOffset,y:pageYOffset}}function O(e,t){return e.getAttribute(`data-sveltekit-${t}`)}var xe={...T,"":T.hover};function Se(e){let t=e.assignedSlot??e.parentNode;return t?.nodeType===11&&(t=t.host),t}function Ce(e,t){for(;e&&e!==t;){if(e.nodeName.toUpperCase()===`A`&&e.hasAttribute(`href`))return e;e=Se(e)}}function we(e,t,n){let r;try{if(r=new URL(e instanceof SVGAElement?e.href.baseVal:e.href,document.baseURI),n&&r.hash.match(/^#[^/]/)){let e=location.hash.split(`#`)[1]||`/`;r.hash=`#${e}${r.hash}`}}catch{}let i=e instanceof SVGAElement?e.target.baseVal:e.target,a=!r||!!i||A(r,t,n)||(e.getAttribute(`rel`)||``).split(/\s+/).includes(`external`),o=r?.origin===E&&e.hasAttribute(`download`);return{url:r,external:a,target:i,download:o}}function k(e){let t=null,n=null,r=null,i=null,a=null,o=null,s=e;for(;s&&s!==document.documentElement;)r===null&&(r=O(s,`preload-code`)),i===null&&(i=O(s,`preload-data`)),t===null&&(t=O(s,`keepfocus`)),n===null&&(n=O(s,`noscroll`)),a===null&&(a=O(s,`reload`)),o===null&&(o=O(s,`replacestate`)),s=Se(s);function c(e){switch(e){case``:case`true`:return!0;case`off`:case`false`:return!1;default:return}}return{preload_code:xe[r??`off`],preload_data:xe[i??`off`],keepfocus:c(t),noscroll:c(n),reload:c(a),replace_state:c(o)}}function Te(e){let t=r(e),n=!0;function i(){n=!0,t.update(e=>e)}function a(e){n=!1,t.set(e)}function o(e){let r;return t.subscribe(t=>{(r===void 0||n&&t!==r)&&e(r=t)})}return{notify:i,set:a,subscribe:o}}var Ee={v:h};function De(){let{set:e,subscribe:t}=r(!1);async function n(){clearTimeout(void 0);try{let t=await fetch(`${pe}/_app/version.json`,{headers:{pragma:`no-cache`,"cache-control":`no-cache`}});if(!t.ok)return!1;let n=(await t.json()).version!==ge;return n&&(e(!0),Ee.v(),clearTimeout(void 0)),n}catch{return!1}}return{subscribe:t,check:n}}function A(e,t,n){return e.origin!==E||!e.pathname.startsWith(t)?!0:n?e.pathname!==location.pathname:!1}function Oe(e){}var ke=new Set([`load`,`prerender`,`csr`,`ssr`,`trailingSlash`,`config`]);[...ke],[...new Set([...ke])];function Ae(e){return e.filter(e=>e!=null)}function j(e,t){return e+`/`+t}function je(e){return e instanceof c||e instanceof u?e.status:500}function Me(e){return e instanceof u?e.text:`Internal Error`}var M,N,P,Ne=a.toString().includes(`$$`)||/function \w+\(\) \{\}/.test(a.toString()),Pe=`a:`;Ne?(M={data:{},form:null,error:null,params:{},route:{id:null},state:{},status:-1,url:new URL(Pe)},N={current:null},P={current:!1}):(M=new class{#e=i({});get data(){return n(this.#e)}set data(e){s(this.#e,e)}#t=i(null);get form(){return n(this.#t)}set form(e){s(this.#t,e)}#n=i(null);get error(){return n(this.#n)}set error(e){s(this.#n,e)}#r=i({});get params(){return n(this.#r)}set params(e){s(this.#r,e)}#i=i({id:null});get route(){return n(this.#i)}set route(e){s(this.#i,e)}#a=i({});get state(){return n(this.#a)}set state(e){s(this.#a,e)}#o=i(-1);get status(){return n(this.#o)}set status(e){s(this.#o,e)}#s=i(new URL(Pe));get url(){return n(this.#s)}set url(e){s(this.#s,e)}},N=new class{#e=i(null);get current(){return n(this.#e)}set current(e){s(this.#e,e)}},P=new class{#e=i(!1);get current(){return n(this.#e)}set current(e){s(this.#e,e)}},Ee.v=()=>P.current=!0);function Fe(e){Object.assign(M,e)}var{onMount:Ie,tick:Le}=o,Re=new Set([`icon`,`shortcut icon`,`apple-touch-icon`]),F=null,I=de(`sveltekit:scroll`)??{},L=de(`sveltekit:snapshot`)??{},R={url:Te({}),page:Te({}),navigating:r(null),updated:De()};function ze(e){I[e]=D()}function Be(e,t){let n=e+1;for(;I[n];)delete I[n],n+=1;for(n=t+1;L[n];)delete L[n],n+=1}function z(e,t=!1){return t?location.replace(e.href):location.href=e.href,new Promise(h)}async function Ve(){if(`serviceWorker`in navigator){let e=await navigator.serviceWorker.getRegistration(S||`/`);e&&await e.update()}}var He,Ue,We,B,Ge,V,Ke={},qe={},Je=[],Ye=[],H=null;function Xe(){H?.fork?.then(e=>e?.discard()),H=null,Q={element:void 0,href:void 0}}var Ze=new Map,Qe=new Set,$e=new Set,U=new Set,W={branch:[],error:null,url:null,nav:null},et=!1,tt=!1,nt=!0,G=!1,K=!1,rt=!1,it=!1,at,q,J,Y,ot=new Set,st=new Map,ct=new Map;async function lt(e,t,n){if(globalThis.__sveltekit_53zxyu.data){let{q:e={},p:t={},l:n={},f:r={}}=globalThis.__sveltekit_53zxyu.data;for(let t in e)Ke[t]=e[t];for(let e in n)Ke[e]=n[e];for(let e in r)Ke[e]=r[e];for(let e in t)qe[e]=t[e]}document.URL!==location.href&&(location.href=location.href),V=e,await e.hooks.init?.(),He=ue(e),B=document.documentElement,Ge=t,Ue=e.nodes[0],We=e.nodes[1],Ue(),We(),q=history.state?.[C],J=history.state?.[w],q||(q=J=Date.now(),history.replaceState({...history.state,[C]:q,[w]:J},``));let r=I[q];function i(){r&&(history.scrollRestoration=`manual`,scrollTo(r.x,r.y))}n?(i(),await zt(Ge,n)):(await Z({type:`enter`,url:be(V.hash?Gt(new URL(location.href)):location.href),replace_state:!0}),i()),Rt()}function ut(){Je.length=0,it=!1}function dt(e){Ye.some(e=>e?.snapshot)&&(L[e]=Ye.map(e=>e?.snapshot?.capture()))}function ft(e){L[e]?.forEach((e,t)=>{Ye[t]?.snapshot?.restore(e)})}function pt(){ze(q),fe(ve,I),dt(J),fe(_e,L)}async function mt(e,n,r,i){let a,o;n.invalidateAll&&Xe(),await Z({type:`goto`,url:be(e),keepfocus:n.keepFocus,noscroll:n.noScroll,replace_state:n.replaceState,state:n.state,redirect_count:r,nav_token:i,accept:()=>{if(n.invalidateAll){it=!0,a=new Set;for(let[e,t]of st)for(let[n,r]of t)r.resource?.reset(),a.add(j(e,n));o=new Set;for(let[e,t]of ct)for(let n of t.keys())o.add(j(e,n))}n.invalidate&&n.invalidate.forEach(Lt)}}),n.invalidateAll&&t().then(t).then(()=>{for(let[e,t]of st)for(let[n,{resource:r}]of t)a?.has(j(e,n))&&r.start();for(let[e,t]of ct)for(let[n,{resource:r}]of t)o?.has(j(e,n))&&r.reconnect()})}async function ht(e){if(e.id!==H?.id){Xe();let t={};ot.add(t),H={id:e.id,token:t,promise:Tt({...e,preload:t}).then(e=>(ot.delete(t),e.type===`loaded`&&e.state.error&&Xe(),e)),fork:null}}return H.promise}async function gt(e){let t=(await X(e,!1))?.route;t&&await Promise.all([...t.layouts,t.leaf].filter(Boolean).map(e=>e[1]()))}async function _t(e,t,n){let r={params:W.params,route:{id:W.route?.id??null},url:new URL(location.href)};if(W={...e.state,nav:r},Fe(e.props.page),at=new V.root({target:t,props:{...e.props,stores:R,components:Ye},hydrate:n,sync:!1,transformError:void 0}),await Promise.resolve(),n){let e={from:null,to:{...r,scroll:I[q]??D()},willUnload:!1,type:`enter`,complete:Promise.resolve()};U.forEach(t=>t(e))}ft(J),tt=!0}async function vt({url:e,params:t,branch:n,errors:r,status:i,error:a,route:o,form:s}){let c=`never`;if(S&&(e.pathname===S||e.pathname===S+`/`))c=`always`;else for(let e of n)e?.slash!==void 0&&(c=e.slash);e.pathname=d(e.pathname,c),e.search=e.search;let l={type:`loaded`,state:{url:e,params:t,branch:n,error:a,route:o},props:{constructors:Ae(n).map(e=>e.node.component),page:Wt(M)}};s!==void 0&&(l.props.form=s);let u={},f=!M,p=0;for(let e=0;e<Math.max(n.length,W.branch.length);e+=1){let t=n[e],r=W.branch[e];t?.data!==r?.data&&(f=!0),t&&(u={...u,...t.data},f&&(l.props[`data_${p}`]=u),p+=1)}return(!W.url||e.href!==W.url.href||W.error!==a||s!==void 0&&s!==M.form||f)&&(l.props.page={error:a,params:t,route:{id:o?.id??null},state:{},status:i,url:new URL(e),form:s??null,data:f?u:M.data}),l}async function yt({loader:e,parent:t,url:n,params:r,route:i,server_data_node:a}){let o={dependencies:new Set,params:new Set,parent:!1,route:!1,url:!1,search_params:new Set},s=await e();return{node:s,loader:e,server:a,universal:s.universal?.load?{type:`data`,data:null,uses:o}:null,data:a?.data??null,slash:s.universal?.trailingSlash??a?.slash}}function bt(e,t,n){let r=e instanceof Request?e.url:e,i=new URL(r,n);return i.origin===n.origin&&(r=i.href.slice(n.origin.length)),{resolved:i,promise:tt?y(r,i.href,t):te(r,t)}}function xt(e,t,n,r,i,a){if(it)return!0;if(!i)return!1;if(i.parent&&e||i.route&&t||i.url&&n)return!0;for(let e of i.search_params)if(r.has(e))return!0;for(let e of i.params)if(a[e]!==W.params[e])return!0;for(let e of i.dependencies)if(Je.some(t=>t(new URL(e))))return!0;return!1}function St(e,t){return e?.type===`data`?e:e?.type===`skip`?t??null:null}function Ct(e,t){if(!e)return new Set(t.searchParams.keys());let n=new Set([...e.searchParams.keys(),...t.searchParams.keys()]);for(let r of n){let i=e.searchParams.getAll(r),a=t.searchParams.getAll(r);i.every(e=>a.includes(e))&&a.every(e=>i.includes(e))&&n.delete(r)}return n}function wt({error:e,url:t,route:n,params:r}){return{type:`loaded`,state:{error:e,url:t,route:n,params:r,branch:[]},props:{page:Wt(M),constructors:[]}}}async function Tt({id:e,invalidating:t,url:n,params:r,route:i,preload:a}){if(H?.id===e)return ot.delete(H.token),H.promise;let{errors:o,layouts:s,leaf:u}=i,d=[...s,u];o.forEach(e=>e?.().catch(h)),d.forEach(e=>e?.[1]().catch(h));let f=W.url?e!==At(W.url):!1,p=W.route?i.id!==W.route.id:!1,m=Ct(W.url,n),ee=!1,g=d.map(async(e,t)=>{if(!e)return;let a=W.branch[t];return e[1]===a?.loader&&!xt(ee,p,f,m,a.universal?.uses,r)?a:(ee=!0,yt({loader:e[1],url:n,params:r,route:i,parent:async()=>{let e={};for(let n=0;n<t;n+=1)Object.assign(e,(await g[n])?.data);return e},server_data_node:St(e[0]?{type:`skip`}:null,e[0]?a?.server:void 0)}))});for(let e of g)e.catch(h);let _=[];for(let e=0;e<d.length;e+=1)if(d[e])try{_.push(await g[e])}catch(t){if(t instanceof l)return{type:`redirect`,location:t.location};if(a&&ot.has(a))return wt({error:await $(t,{params:r,url:n,route:{id:i.id}}),url:n,params:r,route:i});let s=je(t),u;if(t instanceof c)u=t.body;else{if(await R.updated.check())return await Ve(),await z(n);u=await $(t,{params:r,url:n,route:{id:i.id}})}let d=await Et(e,_,o);return d?vt({url:n,params:r,branch:_.slice(0,d.idx).concat(d.node),errors:o,status:s,error:u,route:i}):await Mt(n,{id:i.id},u,s)}else _.push(void 0);return vt({url:n,params:r,branch:_,errors:o,status:200,error:null,route:i,form:t?void 0:null})}async function Et(e,t,n){for(;e--;)if(n[e]){let r=e;for(;!t[r];)--r;try{return{idx:r+1,node:{node:await n[e](),loader:n[e],data:{},server:null,universal:null}}}catch{continue}}}async function Dt({status:e,error:t,url:n,route:r}){let i={};try{return vt({url:n,params:i,branch:[await yt({loader:Ue,url:n,params:i,route:r,parent:()=>Promise.resolve({}),server_data_node:St(null)}),{node:await We(),loader:We,universal:null,server:null,data:null}],status:e,error:t,errors:[],route:null})}catch(t){if(t instanceof l){await mt(new URL(t.location,location.href),{},0);return}let a=await V.get_error_template(),o=await $(t,{url:n,params:i,route:r}),s=a({status:e,message:String(o?.message??``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`)}),c=new DOMParser().parseFromString(s,`text/html`);throw document.documentElement.replaceChild(document.adoptNode(c.head),document.head),document.documentElement.replaceChild(document.adoptNode(c.body),document.body),t}}async function Ot(e){let t=e.href;if(Ze.has(t))return Ze.get(t);let n;try{let r=(async()=>{let t=await V.hooks.reroute({url:new URL(e),fetch:async(t,n)=>bt(t,n,e).promise})??e;if(typeof t==`string`){let n=new URL(e);V.hash?n.hash=t:n.pathname=t,t=n}return t})();Ze.set(t,r),n=await r}catch{Ze.delete(t);return}return n}async function X(e,t){if(e&&!A(e,S,V.hash)){let n=await Ot(e);if(!n)return;let r=kt(n);for(let n of He){let i=n.exec(r);if(i)return{id:At(e),invalidating:t,route:n,params:p(i),url:e}}}}function kt(e){return f(V.hash?e.hash.replace(/^#/,``).replace(/[?#].+/,``):e.pathname.slice(S.length))||`/`}function At(e){return(V.hash?e.hash.replace(/^#/,``):e.pathname)+e.search}function jt({url:e,type:t,intent:n,delta:r,event:i,scroll:a}){let o=!1,s=Ut(W,n,e,t,a??null);r!==void 0&&(s.navigation.delta=r),i!==void 0&&(s.navigation.event=i);let c={...s.navigation,cancel:()=>{o=!0,s.reject(Error(`navigation cancelled`))}};return G||Qe.forEach(e=>e(c)),o?null:s}async function Z({type:n,url:r,popped:i,keepfocus:a,noscroll:o,replace_state:s,state:c={},redirect_count:l=0,nav_token:d={},accept:f=h,block:p=h,event:m}){let ee=Y;Y=d;let g=await X(r,!1),_=n===`enter`?Ut(W,g,r,n):jt({url:r,type:n,delta:i?.delta,intent:g,scroll:i?.scroll,event:m});if(!_){p(),Y===d&&(Y=ee);return}let v=q,te=J;f(),G=!0,tt&&_.navigation.type!==`enter`&&R.navigating.set(N.current=_.navigation);let y=g&&await Tt(g);if(!y){if(A(r,S,V.hash))return await z(r,s);y=await Mt(r,{id:null},await $(new u(404,`Not Found`,`Not found: ${r.pathname}`),{url:r,params:{},route:{id:null}}),404,s)}if(r=g?.url||r,Y!==d){_.reject(Error(`navigation aborted`));return}if(!y)return;if(y.type===`redirect`){if(l<20){await Z({type:n,url:new URL(y.location,r),popped:i,keepfocus:a,noscroll:o,replace_state:s,state:c,redirect_count:l+1,nav_token:d}),_.fulfil(void 0);return}if(y=await Dt({status:500,error:await $(Error(`Redirect loop`),{url:r,params:{},route:{id:null}}),url:r,route:{id:null}}),!y)return}else if(y.props.page.status>=400&&await R.updated.check())return await Ve(),await z(r,s);if(ut(),ze(v),dt(te),y.props.page.url.pathname!==r.pathname&&(r.pathname=y.props.page.url.pathname),c=i?i.state:c,!i){let e=+!s,t={[C]:q+=e,[w]:J+=e,[ye]:c};(s?history.replaceState:history.pushState).call(history,t,``,r),s||Be(q,J)}let b=g&&H?.id===g.id?H.fork:null;H?.fork&&!b?Xe():(H=null,Q={element:void 0,href:void 0}),y.props.page.state=c;let ne;if(tt){let t=(await Promise.all(Array.from($e,e=>e(_.navigation)))).filter(e=>typeof e==`function`);if(t.length>0){function e(){t.forEach(e=>{U.delete(e)})}t.push(e),t.forEach(e=>{U.add(e)})}let n=_.navigation.to;W={...y.state,nav:{params:n.params,route:n.route,url:n.url}},y.props.page&&(y.props.page.url=r),!a&&document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur();let i=b&&await b;i?ne=i.commit():(F=null,at.$set(y.props),F&&Object.assign(y.props.page,F),Fe(y.props.page),ne=e?.()),rt=!0}else await _t(y,Ge,!1);let{activeElement:re}=document;if(await ne,await t(),await t(),Y!==d){_.reject(Error(`navigation aborted`));return}y.props.page&&F&&Object.assign(y.props.page,F);let x=null;if(nt){let e=i?i.scroll:o?D():null;e?scrollTo(e.x,e.y):(x=r.hash&&document.getElementById(Kt(r)))?x.scrollIntoView():scrollTo(0,0)}let ie=document.activeElement!==re&&document.activeElement!==document.body;!a&&!ie&&Ht(r,!x),nt=!0,G=!1,_.fulfil(void 0),_.navigation.to&&(_.navigation.to.scroll=D()),U.forEach(e=>e(_.navigation)),n===`popstate`&&ft(J),R.navigating.set(N.current=null)}async function Mt(e,t,n,r,i){return e.origin===E&&e.pathname===location.pathname&&!et?await Dt({status:r,error:n,url:e,route:t}):await z(e,i)}var Q={element:void 0,href:void 0};function Nt(){let e,t;B.addEventListener(`mousemove`,t=>{let n=t.target;clearTimeout(e),e=setTimeout(()=>{i(n,T.hover)},20)});function n(e){e.defaultPrevented||i(e.composedPath()[0],T.tap)}B.addEventListener(`mousedown`,n),B.addEventListener(`touchstart`,n,{passive:!0});let r=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&(gt(new URL(t.target.href)),r.unobserve(t.target))},{threshold:0});async function i(e,n){let r=Ce(e,B),i=r===Q.element&&r?.href===Q.href&&n>=t;if(!r||i)return;let{url:a,external:o,download:s}=we(r,S,V.hash);if(o||s)return;let c=k(r),l=a&&At(W.url)===At(a);if(!(c.reload||l))if(n<=c.preload_data){Q={element:r,href:r.href},t=T.tap;let e=await X(a,!1);if(!e)return;ht(e)}else n<=c.preload_code&&(Q={element:r,href:r.href},t=n,gt(a))}function a(){r.disconnect();for(let e of B.querySelectorAll(`a`)){let{url:t,external:n,download:i}=we(e,S,V.hash);if(n||i)continue;let a=k(e);a.reload||(a.preload_code===T.viewport&&r.observe(e),a.preload_code===T.eager&>(t))}}U.add(a),a()}function $(e,t){if(e instanceof c)return e.body;let n=je(e),r=Me(e);return V.hooks.handleError({error:e,event:t,status:n,message:r})??{message:r}}function Pt(e,t){Ie(()=>(e.add(t),()=>{e.delete(t)}))}function Ft(e){Pt(U,e)}function It(e,t={}){return e=new URL(be(e)),e.origin===E?mt(e,t,0):Promise.reject(Error(`goto: invalid URL`))}function Lt(e){if(typeof e==`function`)Je.push(e);else{let{href:t}=new URL(e,location.href);Je.push(e=>e.href===t)}}function Rt(){history.scrollRestoration=`manual`,addEventListener(`beforeunload`,e=>{let t=!1;if(pt(),!G){let e=Ut(W,void 0,null,`leave`),n={...e.navigation,cancel:()=>{t=!0,e.reject(Error(`navigation cancelled`))}};Qe.forEach(e=>e(n))}t?(e.preventDefault(),e.returnValue=``):history.scrollRestoration=`auto`}),addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&pt()}),navigator.connection?.saveData||Nt(),B.addEventListener(`click`,async t=>{if(t.button||t.which!==1||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||t.defaultPrevented)return;let n=Ce(t.composedPath()[0],B);if(!n)return;let{url:r,external:i,target:a,download:o}=we(n,S,V.hash);if(!r)return;if(a===`_parent`||a===`_top`){if(window.parent!==window)return}else if(a&&a!==`_self`)return;let s=k(n);if(!(n instanceof SVGAElement)&&r.protocol!==location.protocol&&!(r.protocol===`https:`||r.protocol===`http:`)||o)return;let[c,l]=(V.hash?r.hash.replace(/^#/,``):r.href).split(`#`),u=c===m(location);if(i||s.reload&&(!u||!l)){jt({url:r,type:`link`,event:t})?G=!0:t.preventDefault();return}if(l!==void 0&&u){let[,i]=W.url.href.split(`#`);if(i===l){if(t.preventDefault(),l===``||l===`top`&&n.ownerDocument.getElementById(`top`)===null)scrollTo({top:0});else{let e=n.ownerDocument.getElementById(decodeURIComponent(l));e&&(e.scrollIntoView(),e.focus())}return}if(K=!0,ze(q),e(r),!s.replace_state)return;K=!1}t.preventDefault(),await new Promise(e=>{requestAnimationFrame(()=>{setTimeout(e,0)}),setTimeout(e,100)}),await Z({type:`link`,url:r,keepfocus:s.keepfocus,noscroll:s.noscroll,replace_state:s.replace_state??r.href===location.href,event:t})}),B.addEventListener(`submit`,e=>{if(e.defaultPrevented)return;let t=HTMLFormElement.prototype.cloneNode.call(e.target),n=e.submitter;if((n?.formTarget||t.target)===`_blank`||(n?.formMethod||t.method)!==`get`)return;let r=new URL(n?.hasAttribute(`formaction`)&&n?.formAction||t.action);if(A(r,S,!1))return;let i=e.target,a=k(i);if(a.reload)return;e.preventDefault(),e.stopPropagation();let o=new FormData(i,n);r.search=new URLSearchParams(o).toString(),Z({type:`form`,url:r,keepfocus:a.keepfocus,noscroll:a.noscroll,replace_state:a.replace_state??r.href===location.href,event:e})}),addEventListener(`popstate`,async t=>{if(!Vt)if(t.state?.[`sveltekit:history`]){let n=t.state[C];if(Y={},n===q)return;let r=I[n],i=t.state[`sveltekit:states`]??{},a=new URL(t.state[`sveltekit:pageurl`]??location.href),o=t.state[w],s=W.url?m(location)===m(W.url):!1;if(o===J&&(rt||s)){i!==M.state&&(M.state=i),e(a),I[q]=D(),r&&scrollTo(r.x,r.y),q=n;return}let c=n-q;await Z({type:`popstate`,url:a,popped:{state:i,scroll:r,delta:c},accept:()=>{q=n,J=o},block:()=>{history.go(-c)},nav_token:Y,event:t})}else K||(e(new URL(location.href)),V.hash&&location.reload())}),addEventListener(`hashchange`,()=>{K&&(K=!1,history.replaceState({...history.state,[C]:++q,[w]:J},``,location.href))});for(let e of document.querySelectorAll(`link`))Re.has(e.rel)&&(e.href=e.href);addEventListener(`pageshow`,e=>{e.persisted&&R.navigating.set(N.current=null)});function e(e){W.url=M.url=e,R.page.set(Wt(M)),R.page.notify()}}async function zt(e,{status:t=200,error:n,node_ids:r,params:i,route:a,server_route:o,data:s,form:c}){et=!0;let u=new URL(location.href),d;({params:i={},route:a={id:null}}=await X(u,!1)||{}),d=He.find(({id:e})=>e===a.id);let f,p=!0;try{let e=r.map(async(t,n)=>{let r=s[n];return r?.uses&&(r.uses=Bt(r.uses)),yt({loader:V.nodes[t],url:u,params:i,route:a,parent:async()=>{let t={};for(let r=0;r<n;r+=1)Object.assign(t,(await e[r]).data);return t},server_data_node:St(r)})}),o=await Promise.all(e);if(d){let e=d.layouts;for(let t=0;t<e.length;t++)e[t]||o.splice(t,0,void 0)}f=await vt({url:u,params:i,branch:o,status:t,error:n,errors:d?.errors,form:c,route:d??null})}catch(t){if(t instanceof l)return await z(new URL(t.location,location.href));f=await Dt({status:je(t),error:await $(t,{url:u,params:i,route:a}),url:u,route:a}),e.textContent=``,p=!1}f&&(f.props.page&&(f.props.page.state={}),await _t(f,e,p))}function Bt(e){return{dependencies:new Set(e?.dependencies??[]),params:new Set(e?.params??[]),parent:!!e?.parent,route:!!e?.route,url:!!e?.url,search_params:new Set(e?.search_params??[])}}var Vt=!1;function Ht(e,t=!0){let n=document.querySelector(`[autofocus]`);if(n)n.focus();else{let n=Kt(e);if(n&&document.getElementById(n)){let{x:r,y:i}=D();setTimeout(()=>{let a=history.state;Vt=!0,location.replace(new URL(`#${n}`,location.href)),history.replaceState(a,``,e),t&&scrollTo(r,i),Vt=!1})}else{let e=document.body,t=e.getAttribute(`tabindex`);e.tabIndex=-1,e.focus({preventScroll:!0,focusVisible:!1}),t===null?e.removeAttribute(`tabindex`):e.setAttribute(`tabindex`,t)}let r=getSelection();if(r&&r.type!==`None`){let e=[];for(let t=0;t<r.rangeCount;t+=1)e.push(r.getRangeAt(t));setTimeout(()=>{if(r.rangeCount===e.length){for(let t=0;t<r.rangeCount;t+=1){let n=e[t],i=r.getRangeAt(t);if(n.commonAncestorContainer!==i.commonAncestorContainer||n.startContainer!==i.startContainer||n.endContainer!==i.endContainer||n.startOffset!==i.startOffset||n.endOffset!==i.endOffset)return}r.removeAllRanges()}})}}}function Ut(e,t,n,r,i=null){let a,o,s=new Promise((e,t)=>{a=e,o=t});return s.catch(h),{navigation:{from:{params:e.params,route:{id:e.route?.id??null},url:e.url,scroll:D()},to:n&&{params:t?.params??null,route:{id:t?.route?.id??null},url:n,scroll:i},willUnload:!t,type:r,complete:s},fulfil:a,reject:o}}function Wt(e){return{data:e.data,error:e.error,form:e.form,params:e.params,route:e.route,state:e.state,status:e.status,url:e.url}}function Gt(e){let t=new URL(e);return t.hash=decodeURIComponent(e.hash),t}function Kt(e){let t;if(V.hash){let[,,n]=e.hash.split(`#`,3);t=n??``}else t=e.hash.slice(1);return decodeURIComponent(t)}export{N as a,Oe as c,R as i,he as l,It as n,M as o,lt as r,P as s,Ft as t};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as e,r as t}from"../chunks/DGy-bMvO.js";export{e as load_css,t as start};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|