aberdeen 1.1.0 → 1.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.
@@ -1,4 +1,4 @@
1
- var H=Symbol("matchFailed"),G=Symbol("matchRest");class J{routes=[];addRoute(...q){let j=q.slice(0,-1),k=q[q.length-1];if(typeof k!=="function")throw new Error("Last argument should be a handler function");if(j.filter((C)=>C===G).length>1)throw new Error("Only one matchRest is allowed");this.routes.push({matchers:j,handler:k})}dispatch(q){for(let j of this.routes){let k=K(j,q);if(k)return j.handler(...k),!0}return!1}}function K(q,j){let k=[],B=0;for(let C of q.matchers){if(C===G){let z=j.length-(q.matchers.length-1);if(z<0)return;k.push(j.slice(B,B+z)),B+=z;continue}if(B>=j.length)return;let E=j[B];if(typeof C==="string"){if(E!==C)return}else if(typeof C==="function"){let z=C(E);if(z===H||typeof z==="number"&&isNaN(z))return;k.push(z)}B++}return k}export{G as matchRest,H as matchFailed,J as Dispatcher};
1
+ var H=Symbol("matchFailed"),G=Symbol("matchRest");class J{routes=[];addRoute(...q){let j=q.slice(0,-1),k=q[q.length-1];if(typeof k!=="function")throw Error("Last argument should be a handler function");if(j.filter((C)=>C===G).length>1)throw Error("Only one matchRest is allowed");this.routes.push({matchers:j,handler:k})}dispatch(q){for(let j of this.routes){let k=K(j,q);if(k)return j.handler(...k),!0}return!1}}function K(q,j){let k=[],B=0;for(let C of q.matchers){if(C===G){let z=j.length-(q.matchers.length-1);if(z<0)return;k.push(j.slice(B,B+z)),B+=z;continue}if(B>=j.length)return;let E=j[B];if(typeof C==="string"){if(E!==C)return}else if(typeof C==="function"){let z=C(E);if(z===H||typeof z==="number"&&isNaN(z))return;k.push(z)}B++}return k}export{G as matchRest,H as matchFailed,J as Dispatcher};
2
2
 
3
- //# debugId=80743EF466EF1C6E64756E2164756E21
3
+ //# debugId=DE8D81380A22066F64756E2164756E21
4
4
  //# sourceMappingURL=dispatcher.js.map
@@ -4,7 +4,7 @@
4
4
  "sourcesContent": [
5
5
  "/**\n * Symbol to return when a custom {@link Dispatcher.addRoute} matcher cannot match a segment.\n */\nexport const matchFailed: unique symbol = Symbol(\"matchFailed\");\n\n/**\n * Special {@link Dispatcher.addRoute} matcher that matches the rest of the segments as an array of strings.\n */\nexport const matchRest: unique symbol = Symbol(\"matchRest\");\n\ntype Matcher = string | ((segment: string) => any) | typeof matchRest;\n\ntype ExtractParamType<M> = M extends string\n? never : (\n M extends ((segment: string) => infer R)\n ? Exclude<R, typeof matchFailed>\n : (M extends typeof matchRest ? string[] : never)\n);\n\ntype ParamsFromMatchers<T extends Matcher[]> = T extends [infer M1, ...infer Rest]\n? (\n M1 extends Matcher\n ? (\n ExtractParamType<M1> extends never\n ? ParamsFromMatchers<Rest extends Matcher[] ? Rest : []>\n : [ExtractParamType<M1>, ...ParamsFromMatchers<Rest extends Matcher[] ? Rest : []>]\n ) : never\n) : [];\n\ninterface DispatcherRoute {\n matchers: Matcher[];\n handler: (...params: any[]) => void;\n}\n\n/**\n * Simple route matcher and dispatcher.\n * \n * Example usage:\n * \n * ```ts\n * const dispatcher = new Dispatcher();\n * \n * dispatcher.addRoute(\"user\", Number, \"stream\", String, (id, stream) => {\n * console.log(`User ${id}, stream ${stream}`);\n * });\n *\n * dispatcher.dispatch([\"user\", \"42\", \"stream\", \"music\"]);\n * // Logs: User 42, stream music\n * \n * dispatcher.addRoute(\"search\", matchRest, (terms: string[]) => {\n * console.log(\"Search terms:\", terms);\n * });\n * \n * dispatcher.dispatch([\"search\", \"classical\", \"piano\"]);\n * // Logs: Search terms: [ 'classical', 'piano' ]\n * ```\n */\nexport class Dispatcher {\n private routes: Array<DispatcherRoute> = [];\n \n /**\n * Add a route with matchers and a handler function.\n * @param args An array of matchers followed by a handler function. Each matcher can be:\n * - A string: matches exactly that string.\n * - A function: takes a string segment and returns a value (of any type) if it matches, or {@link matchFailed} if it doesn't match. The return value (if not `matchFailed` and not `NaN`) is passed as a parameter to the handler function. The built-in functions `Number` and `String` can be used to match numeric and string segments respectively.\n * - The special {@link matchRest} symbol: matches the rest of the segments as an array of strings. Only one `matchRest` is allowed, and it must be the last matcher.\n * @template T - Array of matcher types.\n * @template H - Handler function type, inferred from the matchers.\n */\n addRoute<T extends Matcher[], H extends (...args: ParamsFromMatchers<T>) => void>(...args: [...T, H]): void {\n const matchers = args.slice(0, -1) as Matcher[];\n const handler = args[args.length - 1] as (...args: any) => any;\n\n if (typeof handler !== \"function\") {\n throw new Error(\"Last argument should be a handler function\");\n }\n \n const restCount = matchers.filter(m => m === matchRest).length;\n if (restCount > 1) {\n throw new Error(\"Only one matchRest is allowed\");\n }\n\n this.routes.push({ matchers, handler });\n }\n \n /**\n * Dispatches the given segments to the first route handler that matches.\n * @param segments Array of string segments to match against the added routes. When using this class with the Aberdeen `route` module, one would typically pass `route.current.p`.\n * @returns True if a matching route was found and handled, false otherwise.\n */\n dispatch(segments: string[]): boolean {\n for (const route of this.routes) {\n const args = matchRoute(route, segments);\n if (args) {\n route.handler(...args);\n return true;\n }\n }\n return false;\n }\n}\n\nfunction matchRoute(route: DispatcherRoute, segments: string[]): any[] | undefined {\n const args: any[] = [];\n let segmentIndex = 0;\n\n for (const matcher of route.matchers) {\n if (matcher === matchRest) {\n const len = segments.length - (route.matchers.length - 1);\n if (len < 0) return;\n args.push(segments.slice(segmentIndex, segmentIndex + len));\n segmentIndex += len;\n continue;\n }\n\n if (segmentIndex >= segments.length) return;\n const segment = segments[segmentIndex];\n \n if (typeof matcher === \"string\") {\n if (segment !== matcher) return;\n } else if (typeof matcher === \"function\") {\n const result = matcher(segment);\n if (result === matchFailed || (typeof result === 'number' && isNaN(result))) return;\n args.push(result);\n }\n \n segmentIndex++;\n }\n return args; // success!\n}\n"
6
6
  ],
7
- "mappings": "AAGO,IAAM,EAA6B,OAAO,aAAa,EAKjD,EAA2B,OAAO,WAAW,EAiDnD,MAAM,CAAW,CACZ,OAAiC,CAAC,EAW1C,QAAiF,IAAI,EAAuB,CACxG,IAAM,EAA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GAAI,OAAO,IAAY,WACnB,MAAU,MAAM,4CAA4C,EAIhE,GADkB,EAAS,OAAO,KAAK,IAAM,CAAS,EAAE,OACxC,EACZ,MAAU,MAAM,+BAA+B,EAGnD,KAAK,OAAO,KAAK,CAAE,WAAU,SAAQ,CAAC,EAQ1C,QAAQ,CAAC,EAA6B,CAClC,QAAW,KAAS,KAAK,OAAQ,CAC7B,IAAM,EAAO,EAAW,EAAO,CAAQ,EACvC,GAAI,EAEA,OADA,EAAM,QAAQ,GAAG,CAAI,EACd,GAGf,MAAO,GAEf,CAEA,SAAS,CAAU,CAAC,EAAwB,EAAuC,CAC/E,IAAM,EAAc,CAAC,EACjB,EAAe,EAEnB,QAAW,KAAW,EAAM,SAAU,CAClC,GAAI,IAAY,EAAW,CACvB,IAAM,EAAM,EAAS,QAAU,EAAM,SAAS,OAAS,GACvD,GAAI,EAAM,EAAG,OACb,EAAK,KAAK,EAAS,MAAM,EAAc,EAAe,CAAG,CAAC,EAC1D,GAAgB,EAChB,SAGJ,GAAI,GAAgB,EAAS,OAAQ,OACrC,IAAM,EAAU,EAAS,GAEzB,GAAI,OAAO,IAAY,UACnB,GAAI,IAAY,EAAS,OACtB,QAAI,OAAO,IAAY,WAAY,CACtC,IAAM,EAAS,EAAQ,CAAO,EAC9B,GAAI,IAAW,GAAgB,OAAO,IAAW,UAAY,MAAM,CAAM,EAAI,OAC7E,EAAK,KAAK,CAAM,EAGpB,IAEJ,OAAO",
8
+ "debugId": "DE8D81380A22066F64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,4 +1,4 @@
1
- import{defaultEmitHandler as W,withEmitHandler as X}from"./aberdeen.js";function S(G){let C=new Map;return X((B,z,I,J)=>{U(C,B,z,I,J)},G),C}function U(G,C,B,z,I){let J=G.get(C);if(!J)J=new Map,G.set(C,J);let K=J.get(B),L=K?K[1]:I;if(z===L)J.delete(B);else J.set(B,[z,L])}function V(G){for(let[C,B]of G)for(let[z,[I,J]]of B)W(C,z,I,J)}function Q(G,C,B=!1){for(let[z,I]of C)for(let[J,[K,L]]of I)U(G,z,J,B?L:K,B?K:L)}function R(G,C=!1){for(let[B,z]of G)for(let[I,[J,K]]of z){let L=B[I];if(L!==K)if(C)setTimeout(()=>{throw new Error(`Applying invalid patch: data ${L} is unequal to expected old data ${K} for index ${I}`)},0);else return!1}for(let[B,z]of G)for(let[I,[J,K]]of z)B[I]=J;return!0}var N=[];function Z(G){let C=S(G);return N.push(C),V(C),C}function _(G,C=[]){let B=new Map;for(let z of N)Q(B,z,!0);R(B,!0);for(let z of C){let I=N.indexOf(z);if(I>=0)N.splice(I,1)}if(G)Q(B,S(G));for(let z=0;z<N.length;z++)if(R(N[z]))Q(B,N[z]);else N.splice(z,1),z--;V(B)}export{Z as applyPrediction,_ as applyCanon};
1
+ import{defaultEmitHandler as W,withEmitHandler as X}from"./aberdeen.js";function S(G){let C=new Map;return X((B,z,I,J)=>{U(C,B,z,I,J)},G),C}function U(G,C,B,z,I){let J=G.get(C);if(!J)J=new Map,G.set(C,J);let K=J.get(B),L=K?K[1]:I;if(z===L)J.delete(B);else J.set(B,[z,L])}function V(G){for(let[C,B]of G)for(let[z,[I,J]]of B)W(C,z,I,J)}function Q(G,C,B=!1){for(let[z,I]of C)for(let[J,[K,L]]of I)U(G,z,J,B?L:K,B?K:L)}function R(G,C=!1){for(let[B,z]of G)for(let[I,[J,K]]of z){let L=B[I];if(L!==K)if(C)setTimeout(()=>{throw Error(`Applying invalid patch: data ${L} is unequal to expected old data ${K} for index ${I}`)},0);else return!1}for(let[B,z]of G)for(let[I,[J,K]]of z)B[I]=J;return!0}var N=[];function Z(G){let C=S(G);return N.push(C),V(C),C}function _(G,C=[]){let B=new Map;for(let z of N)Q(B,z,!0);R(B,!0);for(let z of C){let I=N.indexOf(z);if(I>=0)N.splice(I,1)}if(G)Q(B,S(G));for(let z=0;z<N.length;z++)if(R(N[z]))Q(B,N[z]);else N.splice(z,1),z--;V(B)}export{Z as applyPrediction,_ as applyCanon};
2
2
 
3
- //# debugId=277071596D78B55D64756E2164756E21
3
+ //# debugId=4067069B259E531864756E2164756E21
4
4
  //# sourceMappingURL=prediction.js.map
@@ -4,7 +4,7 @@
4
4
  "sourcesContent": [
5
5
  "import { defaultEmitHandler, withEmitHandler } from \"./aberdeen.js\";\nimport type { TargetType } from \"./aberdeen.js\";\n\n/**\n * Represents a set of changes that can be applied to proxied objects.\n * This is an opaque type - its internal structure is not part of the public API.\n * @private\n */\nexport type Patch = Map<TargetType, Map<any, [any, any]>>;\n\nfunction recordPatch(func: () => void): Patch {\n\tconst recordingPatch = new Map();\n\twithEmitHandler((target, index, newData, oldData) => {\n\t\taddToPatch(recordingPatch, target, index, newData, oldData);\n\t}, func);\n\treturn recordingPatch;\n}\n\nfunction addToPatch(\n\tpatch: Patch,\n\tcollection: TargetType,\n\tindex: any,\n\tnewData: any,\n\toldData: any,\n) {\n\tlet collectionMap = patch.get(collection);\n\tif (!collectionMap) {\n\t\tcollectionMap = new Map();\n\t\tpatch.set(collection, collectionMap);\n\t}\n\tconst prev = collectionMap.get(index);\n\tconst oldData0 = prev ? prev[1] : oldData;\n\tif (newData === oldData0) collectionMap.delete(index);\n\telse collectionMap.set(index, [newData, oldData0]);\n}\n\nfunction emitPatch(patch: Patch) {\n\tfor (const [collection, collectionMap] of patch) {\n\t\tfor (const [index, [newData, oldData]] of collectionMap) {\n\t\t\tdefaultEmitHandler(collection, index, newData, oldData);\n\t\t}\n\t}\n}\n\nfunction mergePatch(target: Patch, source: Patch, reverse = false) {\n\tfor (const [collection, collectionMap] of source) {\n\t\tfor (const [index, [newData, oldData]] of collectionMap) {\n\t\t\taddToPatch(\n\t\t\t\ttarget,\n\t\t\t\tcollection,\n\t\t\t\tindex,\n\t\t\t\treverse ? oldData : newData,\n\t\t\t\treverse ? newData : oldData,\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction silentlyApplyPatch(patch: Patch, force = false): boolean {\n\tfor (const [collection, collectionMap] of patch) {\n\t\tfor (const [index, [newData, oldData]] of collectionMap) {\n\t\t\tconst actualData = (collection as any)[index];\n\t\t\tif (actualData !== oldData) {\n\t\t\t\tif (force)\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Applying invalid patch: data ${actualData} is unequal to expected old data ${oldData} for index ${index}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}, 0);\n\t\t\t\telse return false;\n\t\t\t}\n\t\t}\n\t}\n\tfor (const [collection, collectionMap] of patch) {\n\t\tfor (const [index, [newData, oldData]] of collectionMap) {\n\t\t\t(collection as any)[index] = newData;\n\t\t}\n\t}\n\treturn true;\n}\n\nconst appliedPredictions: Array<Patch> = [];\n\n/**\n * Run the provided function, while treating all changes to Observables as predictions,\n * meaning they will be reverted when changes come back from the server (or some other\n * async source).\n * @param predictFunc The function to run. It will generally modify some Observables\n * \tto immediately reflect state (as closely as possible) that we expect the server\n * to communicate back to us later on.\n * @returns A `Patch` object. Don't modify it. This is only meant to be passed to `applyCanon`.\n */\nexport function applyPrediction(predictFunc: () => void): Patch {\n\tconst patch = recordPatch(predictFunc);\n\tappliedPredictions.push(patch);\n\temitPatch(patch);\n\treturn patch;\n}\n\n/**\n * Temporarily revert all outstanding predictions, optionally run the provided function\n * (which will generally make authoritative changes to the data based on a server response),\n * and then attempt to reapply the predictions on top of the new canonical state, dropping\n * any predictions that can no longer be applied cleanly (the data has been modified) or\n * that were specified in `dropPredictions`.\n *\n * All of this is done such that redraws are only triggered if the overall effect is an\n * actual change to an `Observable`.\n * @param canonFunc The function to run without any predictions applied. This will typically\n * make authoritative changes to the data, based on a server response.\n * @param dropPredictions An optional list of predictions (as returned by `applyPrediction`)\n * to undo. Typically, when a server response for a certain request is being handled,\n * you'd want to drop the prediction that was done for that request.\n */\nexport function applyCanon(\n\tcanonFunc?: () => void,\n\tdropPredictions: Array<Patch> = [],\n) {\n\tconst resultPatch = new Map();\n\tfor (const prediction of appliedPredictions)\n\t\tmergePatch(resultPatch, prediction, true);\n\tsilentlyApplyPatch(resultPatch, true);\n\n\tfor (const prediction of dropPredictions) {\n\t\tconst pos = appliedPredictions.indexOf(prediction);\n\t\tif (pos >= 0) appliedPredictions.splice(pos, 1);\n\t}\n\tif (canonFunc) mergePatch(resultPatch, recordPatch(canonFunc));\n\n\tfor (let idx = 0; idx < appliedPredictions.length; idx++) {\n\t\tif (silentlyApplyPatch(appliedPredictions[idx])) {\n\t\t\tmergePatch(resultPatch, appliedPredictions[idx]);\n\t\t} else {\n\t\t\tappliedPredictions.splice(idx, 1);\n\t\t\tidx--;\n\t\t}\n\t}\n\n\temitPatch(resultPatch);\n}\n"
6
6
  ],
7
- "mappings": "AAAA,6BAAS,qBAAoB,sBAU7B,SAAS,CAAW,CAAC,EAAyB,CAC7C,IAAM,EAAiB,IAAI,IAI3B,OAHA,EAAgB,CAAC,EAAQ,EAAO,EAAS,IAAY,CACpD,EAAW,EAAgB,EAAQ,EAAO,EAAS,CAAO,GACxD,CAAI,EACA,EAGR,SAAS,CAAU,CAClB,EACA,EACA,EACA,EACA,EACC,CACD,IAAI,EAAgB,EAAM,IAAI,CAAU,EACxC,IAAK,EACJ,EAAgB,IAAI,IACpB,EAAM,IAAI,EAAY,CAAa,EAEpC,IAAM,EAAO,EAAc,IAAI,CAAK,EAC9B,EAAW,EAAO,EAAK,GAAK,EAClC,GAAI,IAAY,EAAU,EAAc,OAAO,CAAK,EAC/C,OAAc,IAAI,EAAO,CAAC,EAAS,CAAQ,CAAC,EAGlD,SAAS,CAAS,CAAC,EAAc,CAChC,QAAY,EAAY,KAAkB,EACzC,QAAY,GAAQ,EAAS,MAAa,EACzC,EAAmB,EAAY,EAAO,EAAS,CAAO,EAKzD,SAAS,CAAU,CAAC,EAAe,EAAe,EAAU,GAAO,CAClE,QAAY,EAAY,KAAkB,EACzC,QAAY,GAAQ,EAAS,MAAa,EACzC,EACC,EACA,EACA,EACA,EAAU,EAAU,EACpB,EAAU,EAAU,CACrB,EAKH,SAAS,CAAk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,EAAM,EAAmB,QAAQ,CAAU,EACjD,GAAI,GAAO,EAAG,EAAmB,OAAO,EAAK,CAAC,EAE/C,GAAI,EAAW,EAAW,EAAa,EAAY,CAAS,CAAC,EAE7D,QAAS,EAAM,EAAG,EAAM,EAAmB,OAAQ,IAClD,GAAI,EAAmB,EAAmB,EAAI,EAC7C,EAAW,EAAa,EAAmB,EAAI,EAE/C,OAAmB,OAAO,EAAK,CAAC,EAChC,IAIF,EAAU,CAAW",
8
+ "debugId": "4067069B259E531864756E2164756E21",
9
9
  "names": []
10
10
  }
package/dist-min/route.js CHANGED
@@ -1,4 +1,4 @@
1
- import{clean as B,getParentElement as F,$ as _,proxy as Q,runQueue as f,unproxy as N,copy as O,merge as U,clone as X,leakScope as $}from"./aberdeen.js";var J=()=>{};function d(z){if(z===!0)J=console.log.bind(console,"aberdeen router");else if(z===!1)J=()=>{};else J=z}function j(){return W({path:location.pathname,hash:location.hash,search:Object.fromEntries(new URLSearchParams(location.search)),state:history.state?.state||{}},"load",(history.state?.stack?.length||0)+1)}function V(z,A,D){if(z===A)return!0;if(typeof z!=="object"||!z||typeof A!=="object"||!A)return!1;if(z.constructor!==A.constructor)return!1;if(A instanceof Array){if(z.length!==A.length)return!1;for(let G=0;G<A.length;G++)if(!V(z[G],A[G],D))return!1}else{for(let G of Object.keys(A))if(!V(z[G],A[G],D))return!1;if(!D){for(let G of Object.keys(z))if(!A.hasOwnProperty(G))return!1}}return!0}function E(z){let A=new URLSearchParams(z.search).toString();return(A?`${z.path}?${A}`:z.path)+z.hash}function W(z,A,D){let G=z.path||(z.p||[]).join("/")||"/";if(G=(""+G).replace(/\/+$/,""),!G.startsWith("/"))G=`/${G}`;return{path:G,hash:z.hash&&z.hash!=="#"?z.hash.startsWith("#")?z.hash:"#"+z.hash:"",p:G.length>1?G.slice(1).replace(/\/+$/,"").split("/"):[],nav:A,search:typeof z.search==="object"&&z.search?X(z.search):{},state:typeof z.state==="object"&&z.state?X(z.state):{},depth:D}}function Y(z){if(typeof z==="string")z={path:z};else if(z instanceof Array)z={p:z};if(z.p)z.p=z.p.map(String);if(z.search)for(let A of Object.keys(z.search))z.search[A]=String(z.search[A]);return z}function I(z){L=(history.state?.stack||[]).concat(JSON.stringify(N(H)));let D=W(Y(z),"go",L.length+1);O(H,D),J("go",D),history.pushState({state:D.state,stack:L},"",E(D)),f()}function C(z){let A=X(N(H));U(A,Y(z)),I(A)}function P(z={}){let A=Y(z),D=history.state?.stack||[];for(let K=D.length-1;K>=0;K--){let M=JSON.parse(D[K]);if(V(M,A,!0)){let Z=K-D.length;J("back",Z,M),history.go(Z);return}}let G=W(A,"back",D.length+1);J("back not found, replacing",A),O(H,G)}function S(z=1){let A=N(H).p,D=history.state?.stack||[];for(let K=D.length-1;K>=0;K--){let M=JSON.parse(D[K]);if(M.p.length<A.length&&V(M.p,A.slice(0,M.p.length),!1)){J(`up to ${K+1} / ${D.length}`,M),history.go(K-D.length);return}}let G=W({p:A.slice(0,A.length-z)},"back",D.length+1);J("up not found, replacing",G),O(H,G)}function x(z="main"){let A=F();A.addEventListener("scroll",G),B(()=>A.removeEventListener("scroll",G));let D=N(H).state.scroll?.[z];if(D)J("restoring scroll",z,D),Object.assign(A,D);function G(){(H.state.scroll||={})[z]={scrollTop:A.scrollTop,scrollLeft:A.scrollLeft}}}var L,H=Q({});function T(){L=history.state?.stack||[];let z=j();J("initial",z),O(N(H),z)}T();window.addEventListener("popstate",function(z){let A=j(),D=history.state?.stack||[];if(D.length!==L.length){let G=Math.min(L.length,D.length)-1;if(G<0||D[G]===L[G])A.nav=D.length<L.length?"back":"forward"}L=D,J("popstate",A),O(H,A),f()});$(()=>{_(()=>{H.path="/"+Array.from(H.p).join("/")}),_(()=>{let z=history.state?.stack||[],A=W(H,N(H).nav,z.length+1);O(H,A);let D={state:A.state,stack:z},G=E(A);if(G!==location.pathname+location.search+location.hash||!V(history.state,D,!1))J("replaceState",A,D,G),history.replaceState(D,"",G)})});export{S as up,d as setLog,T as reset,C as push,x as persistScroll,I as go,H as current,P as back};
1
+ import{clean as B,getParentElement as F,$ as _,proxy as Q,runQueue as f,unproxy as N,copy as O,merge as U,clone as X,leakScope as $}from"./aberdeen.js";var J=()=>{};function d(z){if(z===!0)J=console.log.bind(console,"aberdeen router");else if(z===!1)J=()=>{};else J=z}function j(){return W({path:location.pathname,hash:location.hash,search:Object.fromEntries(new URLSearchParams(location.search)),state:history.state?.state||{}},"load",(history.state?.stack?.length||0)+1)}function V(z,A,G){if(z===A)return!0;if(typeof z!=="object"||!z||typeof A!=="object"||!A)return!1;if(z.constructor!==A.constructor)return!1;if(A instanceof Array){if(z.length!==A.length)return!1;for(let D=0;D<A.length;D++)if(!V(z[D],A[D],G))return!1}else{for(let D of Object.keys(A))if(!V(z[D],A[D],G))return!1;if(!G){for(let D of Object.keys(z))if(!A.hasOwnProperty(D))return!1}}return!0}function E(z){let A=new URLSearchParams(z.search).toString();return(A?`${z.path}?${A}`:z.path)+z.hash}function W(z,A,G){let D=z.path||(z.p||[]).join("/")||"/";if(D=(""+D).replace(/\/+$/,""),!D.startsWith("/"))D=`/${D}`;return{path:D,hash:z.hash&&z.hash!=="#"?z.hash.startsWith("#")?z.hash:"#"+z.hash:"",p:D.length>1?D.slice(1).replace(/\/+$/,"").split("/"):[],nav:A,search:typeof z.search==="object"&&z.search?X(z.search):{},state:typeof z.state==="object"&&z.state?X(z.state):{},depth:G}}function Y(z){if(typeof z==="string")z={path:z};else if(z instanceof Array)z={p:z};if(z.p)z.p=z.p.map(String);if(z.search)for(let A of Object.keys(z.search))z.search[A]=String(z.search[A]);return z}function I(z,A="go"){L=(history.state?.stack||[]).concat(JSON.stringify(N(H)));let D=W(Y(z),A,L.length+1);O(H,D),J(A,D),history.pushState({state:D.state,stack:L},"",E(D)),f()}function C(z){let A=X(N(H));U(A,Y(z)),I(A)}function P(z={}){let A=Y(z),G=history.state?.stack||[];for(let K=G.length-1;K>=0;K--){let M=JSON.parse(G[K]);if(V(M,A,!0)){let Z=K-G.length;J("back",Z,M),history.go(Z);return}}let D=W(A,"back",G.length+1);J("back not found, replacing",A),O(H,D)}function S(z=1){let A=N(H).p,G=history.state?.stack||[];for(let K=G.length-1;K>=0;K--){let M=JSON.parse(G[K]);if(M.p.length<A.length&&V(M.p,A.slice(0,M.p.length),!1)){J(`up to ${K+1} / ${G.length}`,M),history.go(K-G.length);return}}let D=W({p:A.slice(0,A.length-z)},"back",G.length+1);J("up not found, replacing",D),O(H,D)}function x(z="main"){let A=F();A.addEventListener("scroll",D),B(()=>A.removeEventListener("scroll",D));let G=N(H).state.scroll?.[z];if(G)J("restoring scroll",z,G),Object.assign(A,G);function D(){(H.state.scroll||={})[z]={scrollTop:A.scrollTop,scrollLeft:A.scrollLeft}}}var L,H=Q({});function T(){L=history.state?.stack||[];let z=j();J("initial",z),O(N(H),z)}T();window.addEventListener("popstate",function(z){let A=j(),G=history.state?.stack||[];if(G.length!==L.length){let D=Math.min(L.length,G.length)-1;if(D<0||G[D]===L[D])A.nav=G.length<L.length?"back":"forward"}L=G,J("popstate",A),O(H,A),f()});$(()=>{_(()=>{H.path="/"+Array.from(H.p).join("/")}),_(()=>{let z=history.state?.stack||[],A=W(H,N(H).nav,z.length+1);O(H,A);let G={state:A.state,stack:z},D=E(A);if(D!==location.pathname+location.search+location.hash||!V(history.state,G,!1))J("replaceState",A,G,D),history.replaceState(G,"",D)})});export{S as up,d as setLog,T as reset,C as push,x as persistScroll,I as go,H as current,P as back};
2
2
 
3
- //# debugId=B6ADEE6973F8780664756E2164756E21
3
+ //# debugId=4AFCE83BFB8282B064756E2164756E21
4
4
  //# sourceMappingURL=route.js.map
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/route.ts"],
4
4
  "sourcesContent": [
5
- "import {clean, getParentElement, $, proxy, runQueue, unproxy, copy, merge, clone, leakScope} from \"./aberdeen.js\";\n\ntype NavType = \"load\" | \"back\" | \"forward\" | \"go\";\n\n/**\n* The class for the global `route` object.\n*/\nexport interface Route {\n\t/** The current path of the URL as a string. For instance `\"/\"` or `\"/users/123/feed\"`. Paths are normalized to always start with a `/` and never end with a `/` (unless it's the root path). */\n\tpath: string;\n\t/** An convenience array containing path segments, mapping to `path`. For instance `[]` (for `\"/\"`) or `['users', '123', 'feed']` (for `\"/users/123/feed\"`). */\n\tp: string[];\n\t/** The hash fragment including the leading `#`, or an empty string. For instance `\"#my_section\"` or `\"\"`. */\n\thash: string;\n\t/** The query string interpreted as search parameters. So `\"a=x&b=y\"` becomes `{a: \"x\", b: \"y\"}`. */\n\tsearch: Record<string, string>;\n\t/** An object to be used for any additional data you want to associate with the current page. Data should be JSON-compatible. */\n\tstate: Record<string, any>;\n\t/** The navigation depth of the current session. Starts at 1. Writing to this property has no effect. */\n\tdepth: number;\n\t/** The navigation action that got us to this page. Writing to this property has no effect.\n\t- `\"load\"`: An initial page load.\n\t- `\"back\"` or `\"forward\"`: When we navigated backwards or forwards in the stack.\n\t- `\"go\"`: When we added a new page on top of the stack.\n\tMostly useful for page transition animations. Writing to this property has no effect.\n\t*/\n\tnav: NavType;\n}\n\nlet log: (...args: any) => void = () => {};\n\n/**\n * Configure logging on route changes.\n * @param value `true` to enable logging to console, `false` to disable logging, or a custom logging function. Defaults to `false`.\n */\nexport function setLog(value: boolean | ((...args: any[]) => void)) {\n\tif (value === true) {\n\t\tlog = console.log.bind(console, 'aberdeen router');\n\t} else if (value === false) {\n\t\tlog = () => {};\n\t} else {\n\t\tlog = value;\n\t}\n}\n\nfunction getRouteFromBrowser(): Route {\n\treturn toCanonRoute({\n\t\tpath: location.pathname,\n\t\thash: location.hash,\n\t\tsearch: Object.fromEntries(new URLSearchParams(location.search)),\n\t\tstate: history.state?.state || {},\n\t}, \"load\", (history.state?.stack?.length || 0) + 1);\n}\n\n/**\n* Deep compare `a` and `b`. If `partial` is true, objects contained in `b` may be a subset\n* of their counterparts in `a` and still be considered equal.\n*/\nfunction equal(a: any, b: any, partial: boolean): boolean {\n\tif (a===b) return true;\n\tif (typeof a !== \"object\" || !a || typeof b !== \"object\" || !b) return false; // otherwise they would have been equal\n\tif (a.constructor !== b.constructor) return false;\n\tif (b instanceof Array) {\n\t\tif (a.length !== b.length) return false;\n\t\tfor(let i = 0; i < b.length; i++) {\n\t\t\tif (!equal(a[i], b[i], partial)) return false;\n\t\t}\n\t} else {\n\t\tfor(const k of Object.keys(b)) {\n\t\t\tif (!equal(a[k], b[k], partial)) return false;\n\t\t}\n\t\tif (!partial) {\n\t\t\tfor(const k of Object.keys(a)) {\n\t\t\t\tif (!b.hasOwnProperty(k)) return false;\n\t\t\t}\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction getUrl(target: Route) {\n\tconst search = new URLSearchParams(target.search).toString();\n\treturn (search ? `${target.path}?${search}` : target.path) + target.hash;\n}\n\nfunction toCanonRoute(target: Partial<Route>, nav: NavType, depth: number): Route {\n\tlet path = target.path || (target.p || []).join(\"/\") || \"/\";\n\tpath = (\"\"+path).replace(/\\/+$/, \"\");\n\tif (!path.startsWith(\"/\")) path = `/${path}`;\n\t\n\treturn {\n\t\tpath,\n\t\thash: target.hash && target.hash !==\"#\" ? (target.hash.startsWith(\"#\") ? target.hash : \"#\" + target.hash) : \"\",\n\t\tp: path.length > 1 ? path.slice(1).replace(/\\/+$/, \"\").split(\"/\") : [],\n\t\tnav,\n\t\tsearch: typeof target.search === 'object' && target.search ? clone(target.search) : {},\n\t\tstate: typeof target.state === 'object' && target.state ? clone(target.state) : {},\n\t\tdepth,\n\t};\n}\n\n\ntype RouteTarget = string | (string|number)[] | Partial<Omit<Omit<Route,\"p\">,\"search\"> & {\n\t/** An convenience array containing path segments, mapping to `path`. For instance `[]` (for `\"/\"`) or `['users', 123, 'feed']` (for `\"/users/123/feed\"`). Values may be integers but will be converted to strings.*/\n\tp: (string|number)[],\n\t/** The query string interpreted as search parameters. So `\"a=x&b=y\"` becomes `{a: \"x\", b: \"y\", c: 42}`. Values may be integers but will be converted to strings. */\n\tsearch: Record<string,string|number>,\n}>;\n\nfunction targetToPartial(target: RouteTarget) {\n\t// Convert shortcut values to objects\n\tif (typeof target === 'string') {\n\t\ttarget = {path: target};\n\t} else if (target instanceof Array) {\n\t\ttarget = {p: target};\n\t}\n\t// Convert numbers in p and search to strings\n\tif (target.p) {\n\t\ttarget.p = target.p.map(String);\n\t}\n\tif (target.search) {\n\t\tfor(const key of Object.keys(target.search)) {\n\t\t\ttarget.search[key] = String(target.search[key]);\n\t\t}\n\t}\n\treturn target as Partial<Route>;\n}\n\n\n/**\n* Navigate to a new URL by pushing a new history entry.\n* \n* Note that this happens synchronously, immediately updating `route` and processing any reactive updates based on that.\n* \n* @param target A subset of the {@link Route} properties to navigate to. If neither `p` nor `path` is given, the current path is used. For other properties, an empty/default value is assumed if not given. For convenience:\n* - You may pass a string instead of an object, which is interpreted as the `path`.\n* - You may pass an array instead of an object, which is interpreted as the `p` array.\n* - If you pass `p`, it may contain numbers, which will be converted to strings.\n* - If you pass `search`, its values may be numbers, which will be converted to strings.\n* \n* Examples:\n* ```js\n* // Navigate to /users/123\n* route.go(\"/users/123\");\n* \n* // Navigate to /users/123?tab=feed#top\n* route.go({p: [\"users\", 123], search: {tab: \"feed\"}, hash: \"top\"});\n* ```\n*/\nexport function go(target: RouteTarget): void {\n\tconst stack: string[] = history.state?.stack || [];\n\n\tprevStack = stack.concat(JSON.stringify(unproxy(current)));\n\t\n\tconst newRoute: Route = toCanonRoute(targetToPartial(target), \"go\", prevStack.length + 1);\n\tcopy(current, newRoute);\n\t\n\tlog('go', newRoute);\n\thistory.pushState({state: newRoute.state, stack: prevStack}, \"\", getUrl(newRoute));\n\t\n\trunQueue();\n}\n\n/**\n * Modify the current route by merging `target` into it (using {@link merge}), pushing a new history entry.\n * \n * This is useful for things like opening modals or side panels, where you want a browser back action to return to the previous state.\n * \n * @param target Same as for {@link go}, but merged into the current route instead deleting all state.\n */\nexport function push(target: RouteTarget): void {\n\tlet copy = clone(unproxy(current));\n\tmerge(copy, targetToPartial(target));\n\tgo(copy);\n}\n\n/**\n * Try to go back in history to the first entry that matches the given target. If none is found, the given state will replace the current page. This is useful for \"cancel\" or \"close\" actions that should return to the previous page if possible, but create a new page if not (for instance when arriving at the current page through a direct link).\n * \n * Consider using {@link up} to go up in the path hierarchy.\n * \n * @param target The target route to go back to. May be a subset of {@link Route}, or a string (for `path`), or an array of strings (for `p`).\n */\nexport function back(target: RouteTarget = {}): void {\n\tconst partial = targetToPartial(target);\n\tconst stack: string[] = history.state?.stack || [];\n\tfor(let i = stack.length - 1; i >= 0; i--) {\n\t\tconst histRoute: Route = JSON.parse(stack[i]);\n\t\tif (equal(histRoute, partial, true)) {\n\t\t\tconst pages = i - stack.length;\n\t\t\tlog(`back`, pages, histRoute);\n\t\t\thistory.go(pages);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tconst newRoute = toCanonRoute(partial, \"back\", stack.length + 1);\n\tlog(`back not found, replacing`, partial);\n\tcopy(current, newRoute);\n}\n\n/**\n* Navigate up in the path hierarchy, by going back to the first history entry\n* that has a shorter path than the current one. If there's none, we just shorten\n* the current path.\n* \n* Note that going back in browser history happens asynchronously, so `route` will not be updated immediately.\n*/\nexport function up(stripCount: number = 1): void {\n\tconst currentP = unproxy(current).p;\n\tconst stack: string[] = history.state?.stack || [];\n\tfor(let i = stack.length - 1; i >= 0; i--) {\n\t\tconst histRoute: Route = JSON.parse(stack[i]);\n\t\tif (histRoute.p.length < currentP.length && equal(histRoute.p, currentP.slice(0, histRoute.p.length), false)) {\n\t\t\t// This route is shorter and matches the start of the current path\n\t\t\tlog(`up to ${i+1} / ${stack.length}`, histRoute);\n\t\t\thistory.go(i - stack.length);\n\t\t\treturn;\n\t\t}\n\t}\n\t// Replace current route with /\n\tconst newRoute = toCanonRoute({p: currentP.slice(0, currentP.length - stripCount)}, \"back\", stack.length + 1);\n\tlog(`up not found, replacing`, newRoute);\n\tcopy(current, newRoute);\n}\n\n/**\n* Restore and store the vertical and horizontal scroll position for\n* the parent element to the page state.\n*\n* @param {string} name - A unique (within this page) name for this\n* scrollable element. Defaults to 'main'.\n*\n* The scroll position will be persisted in `route.aux.scroll.<name>`.\n*/\nexport function persistScroll(name = \"main\") {\n\tconst el = getParentElement();\n\tel.addEventListener(\"scroll\", onScroll);\n\tclean(() => el.removeEventListener(\"scroll\", onScroll));\n\t\n\tconst restore = unproxy(current).state.scroll?.[name];\n\tif (restore) {\n\t\tlog(\"restoring scroll\", name, restore);\n\t\tObject.assign(el, restore);\n\t}\n\t\n\tfunction onScroll() {\n\t\t(current.state.scroll ||= {})[name] = {\n\t\t\tscrollTop: el.scrollTop,\n\t\t\tscrollLeft: el.scrollLeft,\n\t\t};\n\t}\n}\n\nlet prevStack: string[];\n\n/**\n* The global {@link Route} object reflecting the current URL and browser history state. Changes you make to this affect the current browser history item (modifying the URL if needed).\n*/\nexport const current: Route = proxy({}) as Route;\n\n/**\n * Reset the router to its initial state, based on the current browser state. Intended for testing purposes only.\n * @internal\n * */\nexport function reset() {\n\tprevStack = history.state?.stack || [];\n\tconst initRoute = getRouteFromBrowser();\n\tlog('initial', initRoute);\n\tcopy(unproxy(current), initRoute);\n}\nreset();\n\n// Handle browser history back and forward\nwindow.addEventListener(\"popstate\", function(event: PopStateEvent) {\n\tconst newRoute = getRouteFromBrowser();\n\t\n\t// If the stack length changes, and at least the top-most shared entry is the same,\n\t// we'll interpret this as a \"back\" or \"forward\" navigation.\n\tconst stack: string[] = history.state?.stack || [];\n\tif (stack.length !== prevStack.length) {\n\t\tconst maxIndex = Math.min(prevStack.length, stack.length) - 1;\n\t\tif (maxIndex < 0 || stack[maxIndex] === prevStack[maxIndex]) {\n\t\t\tnewRoute.nav = stack.length < prevStack.length ? \"back\" : \"forward\";\n\t\t}\n\t}\n\t// else nav will be \"load\"\n\t\n\tprevStack = stack;\n\tlog('popstate', newRoute);\n\tcopy(current, newRoute);\n\t\n\trunQueue();\n});\n\n// Make sure these observers are never cleaned up, not even by `unmountAll`.\nleakScope(() => {\n\t// Sync `p` to `path`. We need to do this in a separate, higher-priority observer,\n\t// so that setting `route.p` will not be immediately overruled by the pre-existing `route.path`.\n\t$(() => {\n\t\tcurrent.path = \"/\" + Array.from(current.p).join(\"/\");\n\t});\n\n\t// Do a replaceState based on changes to proxy\n\t$(() => {\n\n\t\t// First normalize `route`\n\t\tconst stack = history.state?.stack || [];\n\t\tconst newRoute = toCanonRoute(current, unproxy(current).nav, stack.length + 1);\n\t\tcopy(current, newRoute);\n\t\t\n\t\t// Then replace the current browser state if something actually changed\n\t\tconst state = {state: newRoute.state, stack};\n\t\tconst url = getUrl(newRoute);\n\t\tif (url !== location.pathname + location.search + location.hash || !equal(history.state, state, false)) {\n\t\t\tlog('replaceState', newRoute, state, url);\n\t\t\thistory.replaceState(state, \"\", url);\n\t\t}\n\t});\n});\n"
5
+ "import {clean, getParentElement, $, proxy, runQueue, unproxy, copy, merge, clone, leakScope} from \"./aberdeen.js\";\n\ntype NavType = \"load\" | \"back\" | \"forward\" | \"go\" | \"push\";\n\n/**\n* The class for the global `route` object.\n*/\nexport interface Route {\n\t/** The current path of the URL as a string. For instance `\"/\"` or `\"/users/123/feed\"`. Paths are normalized to always start with a `/` and never end with a `/` (unless it's the root path). */\n\tpath: string;\n\t/** An convenience array containing path segments, mapping to `path`. For instance `[]` (for `\"/\"`) or `['users', '123', 'feed']` (for `\"/users/123/feed\"`). */\n\tp: string[];\n\t/** The hash fragment including the leading `#`, or an empty string. For instance `\"#my_section\"` or `\"\"`. */\n\thash: string;\n\t/** The query string interpreted as search parameters. So `\"a=x&b=y\"` becomes `{a: \"x\", b: \"y\"}`. */\n\tsearch: Record<string, string>;\n\t/** An object to be used for any additional data you want to associate with the current page. Data should be JSON-compatible. */\n\tstate: Record<string, any>;\n\t/** The navigation depth of the current session. Starts at 1. Writing to this property has no effect. */\n\tdepth: number;\n\t/** The navigation action that got us to this page. Writing to this property has no effect.\n\t- `\"load\"`: An initial page load.\n\t- `\"back\"` or `\"forward\"`: When we navigated backwards or forwards in the stack.\n\t- `\"go\"`: When we added a new page on top of the stack.\n\t- `\"push\"`: When we added a new page on top of the stack, merging with the current page.\n\tMostly useful for page transition animations. Writing to this property has no effect.\n\t*/\n\tnav: NavType;\n}\n\nlet log: (...args: any) => void = () => {};\n\n/**\n * Configure logging on route changes.\n * @param value `true` to enable logging to console, `false` to disable logging, or a custom logging function. Defaults to `false`.\n */\nexport function setLog(value: boolean | ((...args: any[]) => void)) {\n\tif (value === true) {\n\t\tlog = console.log.bind(console, 'aberdeen router');\n\t} else if (value === false) {\n\t\tlog = () => {};\n\t} else {\n\t\tlog = value;\n\t}\n}\n\nfunction getRouteFromBrowser(): Route {\n\treturn toCanonRoute({\n\t\tpath: location.pathname,\n\t\thash: location.hash,\n\t\tsearch: Object.fromEntries(new URLSearchParams(location.search)),\n\t\tstate: history.state?.state || {},\n\t}, \"load\", (history.state?.stack?.length || 0) + 1);\n}\n\n/**\n* Deep compare `a` and `b`. If `partial` is true, objects contained in `b` may be a subset\n* of their counterparts in `a` and still be considered equal.\n*/\nfunction equal(a: any, b: any, partial: boolean): boolean {\n\tif (a===b) return true;\n\tif (typeof a !== \"object\" || !a || typeof b !== \"object\" || !b) return false; // otherwise they would have been equal\n\tif (a.constructor !== b.constructor) return false;\n\tif (b instanceof Array) {\n\t\tif (a.length !== b.length) return false;\n\t\tfor(let i = 0; i < b.length; i++) {\n\t\t\tif (!equal(a[i], b[i], partial)) return false;\n\t\t}\n\t} else {\n\t\tfor(const k of Object.keys(b)) {\n\t\t\tif (!equal(a[k], b[k], partial)) return false;\n\t\t}\n\t\tif (!partial) {\n\t\t\tfor(const k of Object.keys(a)) {\n\t\t\t\tif (!b.hasOwnProperty(k)) return false;\n\t\t\t}\n\t\t}\n\t}\n\treturn true;\n}\n\nfunction getUrl(target: Route) {\n\tconst search = new URLSearchParams(target.search).toString();\n\treturn (search ? `${target.path}?${search}` : target.path) + target.hash;\n}\n\nfunction toCanonRoute(target: Partial<Route>, nav: NavType, depth: number): Route {\n\tlet path = target.path || (target.p || []).join(\"/\") || \"/\";\n\tpath = (\"\"+path).replace(/\\/+$/, \"\");\n\tif (!path.startsWith(\"/\")) path = `/${path}`;\n\t\n\treturn {\n\t\tpath,\n\t\thash: target.hash && target.hash !==\"#\" ? (target.hash.startsWith(\"#\") ? target.hash : \"#\" + target.hash) : \"\",\n\t\tp: path.length > 1 ? path.slice(1).replace(/\\/+$/, \"\").split(\"/\") : [],\n\t\tnav,\n\t\tsearch: typeof target.search === 'object' && target.search ? clone(target.search) : {},\n\t\tstate: typeof target.state === 'object' && target.state ? clone(target.state) : {},\n\t\tdepth,\n\t};\n}\n\n\ntype RouteTarget = string | (string|number)[] | Partial<Omit<Omit<Route,\"p\">,\"search\"> & {\n\t/** An convenience array containing path segments, mapping to `path`. For instance `[]` (for `\"/\"`) or `['users', 123, 'feed']` (for `\"/users/123/feed\"`). Values may be integers but will be converted to strings.*/\n\tp: (string|number)[],\n\t/** The query string interpreted as search parameters. So `\"a=x&b=y\"` becomes `{a: \"x\", b: \"y\", c: 42}`. Values may be integers but will be converted to strings. */\n\tsearch: Record<string,string|number>,\n}>;\n\nfunction targetToPartial(target: RouteTarget) {\n\t// Convert shortcut values to objects\n\tif (typeof target === 'string') {\n\t\ttarget = {path: target};\n\t} else if (target instanceof Array) {\n\t\ttarget = {p: target};\n\t}\n\t// Convert numbers in p and search to strings\n\tif (target.p) {\n\t\ttarget.p = target.p.map(String);\n\t}\n\tif (target.search) {\n\t\tfor(const key of Object.keys(target.search)) {\n\t\t\ttarget.search[key] = String(target.search[key]);\n\t\t}\n\t}\n\treturn target as Partial<Route>;\n}\n\n\n/**\n* Navigate to a new URL by pushing a new history entry.\n* \n* Note that this happens synchronously, immediately updating `route` and processing any reactive updates based on that.\n* \n* @param target A subset of the {@link Route} properties to navigate to. If neither `p` nor `path` is given, the current path is used. For other properties, an empty/default value is assumed if not given. For convenience:\n* - You may pass a string instead of an object, which is interpreted as the `path`.\n* - You may pass an array instead of an object, which is interpreted as the `p` array.\n* - If you pass `p`, it may contain numbers, which will be converted to strings.\n* - If you pass `search`, its values may be numbers, which will be converted to strings.\n* \n* Examples:\n* ```js\n* // Navigate to /users/123\n* route.go(\"/users/123\");\n* \n* // Navigate to /users/123?tab=feed#top\n* route.go({p: [\"users\", 123], search: {tab: \"feed\"}, hash: \"top\"});\n* ```\n*/\nexport function go(target: RouteTarget, nav: NavType = \"go\"): void {\n\tconst stack: string[] = history.state?.stack || [];\n\n\tprevStack = stack.concat(JSON.stringify(unproxy(current)));\n\t\n\tconst newRoute: Route = toCanonRoute(targetToPartial(target), nav, prevStack.length + 1);\n\tcopy(current, newRoute);\n\t\n\tlog(nav, newRoute);\n\thistory.pushState({state: newRoute.state, stack: prevStack}, \"\", getUrl(newRoute));\n\t\n\trunQueue();\n}\n\n/**\n * Modify the current route by merging `target` into it (using {@link merge}), pushing a new history entry.\n * \n * This is useful for things like opening modals or side panels, where you want a browser back action to return to the previous state.\n * \n * @param target Same as for {@link go}, but merged into the current route instead deleting all state.\n */\nexport function push(target: RouteTarget): void {\n\tlet copy = clone(unproxy(current));\n\tmerge(copy, targetToPartial(target));\n\tgo(copy);\n}\n\n/**\n * Try to go back in history to the first entry that matches the given target. If none is found, the given state will replace the current page. This is useful for \"cancel\" or \"close\" actions that should return to the previous page if possible, but create a new page if not (for instance when arriving at the current page through a direct link).\n * \n * Consider using {@link up} to go up in the path hierarchy.\n * \n * @param target The target route to go back to. May be a subset of {@link Route}, or a string (for `path`), or an array of strings (for `p`).\n */\nexport function back(target: RouteTarget = {}): void {\n\tconst partial = targetToPartial(target);\n\tconst stack: string[] = history.state?.stack || [];\n\tfor(let i = stack.length - 1; i >= 0; i--) {\n\t\tconst histRoute: Route = JSON.parse(stack[i]);\n\t\tif (equal(histRoute, partial, true)) {\n\t\t\tconst pages = i - stack.length;\n\t\t\tlog(`back`, pages, histRoute);\n\t\t\thistory.go(pages);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tconst newRoute = toCanonRoute(partial, \"back\", stack.length + 1);\n\tlog(`back not found, replacing`, partial);\n\tcopy(current, newRoute);\n}\n\n/**\n* Navigate up in the path hierarchy, by going back to the first history entry\n* that has a shorter path than the current one. If there's none, we just shorten\n* the current path.\n* \n* Note that going back in browser history happens asynchronously, so `route` will not be updated immediately.\n*/\nexport function up(stripCount: number = 1): void {\n\tconst currentP = unproxy(current).p;\n\tconst stack: string[] = history.state?.stack || [];\n\tfor(let i = stack.length - 1; i >= 0; i--) {\n\t\tconst histRoute: Route = JSON.parse(stack[i]);\n\t\tif (histRoute.p.length < currentP.length && equal(histRoute.p, currentP.slice(0, histRoute.p.length), false)) {\n\t\t\t// This route is shorter and matches the start of the current path\n\t\t\tlog(`up to ${i+1} / ${stack.length}`, histRoute);\n\t\t\thistory.go(i - stack.length);\n\t\t\treturn;\n\t\t}\n\t}\n\t// Replace current route with /\n\tconst newRoute = toCanonRoute({p: currentP.slice(0, currentP.length - stripCount)}, \"back\", stack.length + 1);\n\tlog(`up not found, replacing`, newRoute);\n\tcopy(current, newRoute);\n}\n\n/**\n* Restore and store the vertical and horizontal scroll position for\n* the parent element to the page state.\n*\n* @param {string} name - A unique (within this page) name for this\n* scrollable element. Defaults to 'main'.\n*\n* The scroll position will be persisted in `route.aux.scroll.<name>`.\n*/\nexport function persistScroll(name = \"main\") {\n\tconst el = getParentElement();\n\tel.addEventListener(\"scroll\", onScroll);\n\tclean(() => el.removeEventListener(\"scroll\", onScroll));\n\t\n\tconst restore = unproxy(current).state.scroll?.[name];\n\tif (restore) {\n\t\tlog(\"restoring scroll\", name, restore);\n\t\tObject.assign(el, restore);\n\t}\n\t\n\tfunction onScroll() {\n\t\t(current.state.scroll ||= {})[name] = {\n\t\t\tscrollTop: el.scrollTop,\n\t\t\tscrollLeft: el.scrollLeft,\n\t\t};\n\t}\n}\n\nlet prevStack: string[];\n\n/**\n* The global {@link Route} object reflecting the current URL and browser history state. Changes you make to this affect the current browser history item (modifying the URL if needed).\n*/\nexport const current: Route = proxy({}) as Route;\n\n/**\n * Reset the router to its initial state, based on the current browser state. Intended for testing purposes only.\n * @internal\n * */\nexport function reset() {\n\tprevStack = history.state?.stack || [];\n\tconst initRoute = getRouteFromBrowser();\n\tlog('initial', initRoute);\n\tcopy(unproxy(current), initRoute);\n}\nreset();\n\n// Handle browser history back and forward\nwindow.addEventListener(\"popstate\", function(event: PopStateEvent) {\n\tconst newRoute = getRouteFromBrowser();\n\t\n\t// If the stack length changes, and at least the top-most shared entry is the same,\n\t// we'll interpret this as a \"back\" or \"forward\" navigation.\n\tconst stack: string[] = history.state?.stack || [];\n\tif (stack.length !== prevStack.length) {\n\t\tconst maxIndex = Math.min(prevStack.length, stack.length) - 1;\n\t\tif (maxIndex < 0 || stack[maxIndex] === prevStack[maxIndex]) {\n\t\t\tnewRoute.nav = stack.length < prevStack.length ? \"back\" : \"forward\";\n\t\t}\n\t}\n\t// else nav will be \"load\"\n\t\n\tprevStack = stack;\n\tlog('popstate', newRoute);\n\tcopy(current, newRoute);\n\t\n\trunQueue();\n});\n\n// Make sure these observers are never cleaned up, not even by `unmountAll`.\nleakScope(() => {\n\t// Sync `p` to `path`. We need to do this in a separate, higher-priority observer,\n\t// so that setting `route.p` will not be immediately overruled by the pre-existing `route.path`.\n\t$(() => {\n\t\tcurrent.path = \"/\" + Array.from(current.p).join(\"/\");\n\t});\n\n\t// Do a replaceState based on changes to proxy\n\t$(() => {\n\n\t\t// First normalize `route`\n\t\tconst stack = history.state?.stack || [];\n\t\tconst newRoute = toCanonRoute(current, unproxy(current).nav, stack.length + 1);\n\t\tcopy(current, newRoute);\n\t\t\n\t\t// Then replace the current browser state if something actually changed\n\t\tconst state = {state: newRoute.state, stack};\n\t\tconst url = getUrl(newRoute);\n\t\tif (url !== location.pathname + location.search + location.hash || !equal(history.state, state, false)) {\n\t\t\tlog('replaceState', newRoute, state, url);\n\t\t\thistory.replaceState(state, \"\", url);\n\t\t}\n\t});\n});\n"
6
6
  ],
7
- "mappings": "AAAA,gBAAQ,sBAAO,OAAkB,WAAG,cAAO,a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AM,CAGf,EAAE,IAAM,CACP,EAAQ,KAAO,IAAM,MAAM,KAAK,EAAQ,CAAC,EAAE,KAAK,GAAG,EACnD,EAGD,EAAE,IAAM,CAGP,IAAM,EAAQ,QAAQ,OAAO,OAAS,CAAC,EACjC,EAAW,EAAa,EAAS,EAAQ,CAAO,EAAE,IAAK,EAAM,OAAS,CAAC,EAC7E,EAAK,EAAS,CAAQ,EAGtB,IAAM,EAAQ,CAAC,MAAO,EAAS,MAAO,OAAK,EACrC,EAAM,EAAO,CAAQ,EAC3B,GAAI,IAAQ,SAAS,SAAW,SAAS,OAAS,SAAS,MAAQ,CAAC,EAAM,QAAQ,MAAO,EAAO,EAAK,EACpG,EAAI,eAAgB,EAAU,EAAO,CAAG,EACxC,QAAQ,aAAa,EAAO,GAAI,CAAG,EAEpC,EACD",
8
+ "debugId": "4AFCE83BFB8282B064756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -0,0 +1,397 @@
1
+ #!/usr/bin/env node
2
+
3
+ // WARNING: This script was created by Claude Sonnet 3.7, and hasn't
4
+ // received any human code review. It seems to do the job though!
5
+
6
+ export function parseHTML(html) {
7
+ const result = {
8
+ body: []
9
+ };
10
+
11
+ let currentPosition = 0;
12
+ let currentParent = result;
13
+ const stack = [];
14
+
15
+ while (currentPosition < html.length) {
16
+ // Skip whitespace
17
+ while (currentPosition < html.length && /\s/.test(html[currentPosition])) {
18
+ currentPosition++;
19
+ }
20
+
21
+ if (currentPosition >= html.length) break;
22
+
23
+ // Check for comment
24
+ if (html.substring(currentPosition, currentPosition + 4) === '<!--') {
25
+ const endComment = html.indexOf('-->', currentPosition);
26
+ if (endComment === -1) break;
27
+
28
+ const commentContent = html.substring(currentPosition + 4, endComment);
29
+ currentParent.children = currentParent.children || [];
30
+ currentParent.children.push({
31
+ type: 'comment',
32
+ content: commentContent
33
+ });
34
+
35
+ currentPosition = endComment + 3;
36
+ continue;
37
+ }
38
+
39
+ // Check for tag
40
+ if (html[currentPosition] === '<') {
41
+ // Check if it's a closing tag
42
+ if (html[currentPosition + 1] === '/') {
43
+ const endTag = html.indexOf('>', currentPosition);
44
+ if (endTag === -1) break;
45
+
46
+ const tagName = html.substring(currentPosition + 2, endTag).trim().toLowerCase();
47
+
48
+ // Pop from stack
49
+ if (stack.length > 0) {
50
+ currentParent = stack.pop();
51
+ }
52
+
53
+ currentPosition = endTag + 1;
54
+ continue;
55
+ }
56
+
57
+ // It's an opening tag
58
+ const endTag = html.indexOf('>', currentPosition);
59
+ if (endTag === -1) break;
60
+
61
+ const selfClosing = html[endTag - 1] === '/';
62
+ const tagContent = html.substring(currentPosition + 1, selfClosing ? endTag - 1 : endTag).trim();
63
+ const spaceIndex = tagContent.search(/\s/);
64
+
65
+ let tagName, attributesStr;
66
+ if (spaceIndex === -1) {
67
+ tagName = tagContent;
68
+ attributesStr = '';
69
+ } else {
70
+ tagName = tagContent.substring(0, spaceIndex);
71
+ attributesStr = tagContent.substring(spaceIndex + 1);
72
+ }
73
+
74
+ tagName = tagName.toLowerCase();
75
+
76
+ // Parse attributes
77
+ const attributes = [];
78
+ let pos = 0;
79
+
80
+ while (pos < attributesStr.length) {
81
+ // Skip whitespace
82
+ while (pos < attributesStr.length && /\s/.test(attributesStr[pos])) {
83
+ pos++;
84
+ }
85
+ if (pos >= attributesStr.length) break;
86
+
87
+ // Get attribute name
88
+ const nameMatch = attributesStr.substring(pos).match(/^([\w-]+)/);
89
+ if (!nameMatch) break;
90
+
91
+ const name = nameMatch[1];
92
+ pos += name.length;
93
+
94
+ // Skip whitespace
95
+ while (pos < attributesStr.length && /\s/.test(attributesStr[pos])) {
96
+ pos++;
97
+ }
98
+
99
+ // Check for '='
100
+ if (pos < attributesStr.length && attributesStr[pos] === '=') {
101
+ pos++;
102
+
103
+ // Skip whitespace
104
+ while (pos < attributesStr.length && /\s/.test(attributesStr[pos])) {
105
+ pos++;
106
+ }
107
+
108
+ let value = '';
109
+
110
+ if (pos < attributesStr.length) {
111
+ const quoteChar = attributesStr[pos];
112
+
113
+ if (quoteChar === '"' || quoteChar === "'") {
114
+ // Quoted value - handle escaped quotes
115
+ pos++;
116
+ while (pos < attributesStr.length) {
117
+ if (attributesStr[pos] === '\\' && pos + 1 < attributesStr.length) {
118
+ // Escaped character
119
+ value += attributesStr[pos + 1];
120
+ pos += 2;
121
+ } else if (attributesStr[pos] === quoteChar) {
122
+ // End quote
123
+ pos++;
124
+ break;
125
+ } else {
126
+ value += attributesStr[pos];
127
+ pos++;
128
+ }
129
+ }
130
+ } else {
131
+ // Unquoted value
132
+ const unquotedMatch = attributesStr.substring(pos).match(/^(\S+)/);
133
+ if (unquotedMatch) {
134
+ value = unquotedMatch[1];
135
+ pos += value.length;
136
+ }
137
+ }
138
+ }
139
+
140
+ attributes.push({ name, value });
141
+ } else {
142
+ // Boolean attribute
143
+ attributes.push({ name, value: '' });
144
+ }
145
+ }
146
+
147
+ const newElement = {
148
+ type: 'element',
149
+ tagName,
150
+ attributes,
151
+ children: []
152
+ };
153
+
154
+ // Add to current parent
155
+ if (currentParent === result) {
156
+ currentParent.body = currentParent.body || [];
157
+ currentParent.body.push(newElement);
158
+ } else {
159
+ currentParent.children = currentParent.children || [];
160
+ currentParent.children.push(newElement);
161
+ }
162
+
163
+ if (!selfClosing && !['br', 'hr', 'img', 'input', 'link', 'meta'].includes(tagName)) {
164
+ stack.push(currentParent);
165
+ currentParent = newElement;
166
+ }
167
+
168
+ currentPosition = endTag + 1;
169
+ continue;
170
+ }
171
+
172
+ // It's text content
173
+ let endText = html.indexOf('<', currentPosition);
174
+ if (endText === -1) endText = html.length;
175
+
176
+ const textContent = html.substring(currentPosition, endText);
177
+ if (textContent.trim()) {
178
+ if (currentParent === result) {
179
+ currentParent.body = currentParent.body || [];
180
+ currentParent.body.push({
181
+ type: 'text',
182
+ content: textContent
183
+ });
184
+ } else {
185
+ currentParent.children = currentParent.children || [];
186
+ currentParent.children.push({
187
+ type: 'text',
188
+ content: textContent
189
+ });
190
+ }
191
+ }
192
+
193
+ currentPosition = endText;
194
+ }
195
+
196
+ return result;
197
+ }
198
+
199
+ // Read from stdin
200
+ let html = '';
201
+ process.stdin.setEncoding('utf8');
202
+ process.stdin.on('data', (chunk) => {
203
+ html += chunk;
204
+ });
205
+ process.stdin.on('end', () => {
206
+ // Convert HTML to Aberdeen code
207
+ const aberdeenCode = convertHTMLToAberdeen(html);
208
+
209
+ // Output to stdout
210
+ process.stdout.write(aberdeenCode);
211
+ });
212
+
213
+ // Main conversion function
214
+ function convertHTMLToAberdeen(html) {
215
+ // Parse HTML into a simple AST
216
+ const ast = parseHTML(html);
217
+
218
+ // Generate the Aberdeen code
219
+ let aberdeenCode = ``;
220
+
221
+ // Process the body's children
222
+ for (const node of ast.body) {
223
+ aberdeenCode += processNode(node);
224
+ }
225
+
226
+ return aberdeenCode;
227
+ }
228
+
229
+ // Process a node and return Aberdeen code
230
+ function processNode(node, indentLevel = 0) {
231
+ const indent = ' '.repeat(indentLevel);
232
+
233
+ // Handle text nodes
234
+ if (node.type === 'text') {
235
+ const text = node.content.trim();
236
+ return text ? `${indent}$(':${escapeString(text)}');\n` : ``;
237
+ }
238
+
239
+ // Handle comments
240
+ if (node.type === 'comment') {
241
+ return `${indent}// ${node.content.trim()}\n`;
242
+ }
243
+
244
+ // Handle elements
245
+ if (node.type === 'element') {
246
+ return processElement(node, indentLevel);
247
+ }
248
+
249
+ return '';
250
+ }
251
+
252
+ // Process an element node and build the chain of single children
253
+ function processElement(node, indentLevel) {
254
+ const indent = ' '.repeat(indentLevel);
255
+ const chain = getSingleChildChain(node);
256
+
257
+ // Build tag string for each element in the chain
258
+ let result = `${indent}$('`;
259
+ const allSeparateArgs = [];
260
+
261
+ for (let i = 0; i < chain.length; i++) {
262
+ const element = chain[i];
263
+
264
+ // Add space separator between chained elements
265
+ if (i > 0) result += ' ';
266
+
267
+ // Build tag name with classes
268
+ const tagName = element.tagName.toLowerCase();
269
+ const classAttr = element.attributes.find(attr => attr.name === 'class');
270
+ const classes = classAttr
271
+ ? classAttr.value.split(/\s+/).filter(Boolean).map(c => `.${c}`).join('')
272
+ : '';
273
+
274
+ result += tagName + classes;
275
+
276
+ // Add attributes (excluding class)
277
+ const attributes = element.attributes.filter(attr => attr.name !== 'class');
278
+ const { attrString, separateArgs } = buildAttributeString(attributes);
279
+ result += attrString;
280
+
281
+ // Check if this element has only text content
282
+ const hasOnlyText = element.children.length === 1
283
+ && element.children[0].type === 'text'
284
+ && element.children[0].content.trim();
285
+
286
+ if (hasOnlyText) {
287
+ const textContent = element.children[0].content.trim();
288
+ if (i === chain.length - 1) {
289
+ // If it's the last element in the chain and there are no other children,
290
+ // use the ':' syntax for text
291
+ result += ':' + escapeString(textContent);
292
+ } else {
293
+ // Treat text like any other attribute
294
+ const textAttr = { name: 'text', value: textContent };
295
+ const { attrString: textAttrString, separateArgs: textSeparateArgs } = buildAttributeString([textAttr]);
296
+ result += textAttrString;
297
+ separateArgs.push(...textSeparateArgs);
298
+ }
299
+ }
300
+
301
+ allSeparateArgs.push(...separateArgs);
302
+ }
303
+
304
+ result += `'`;
305
+
306
+ // Add all separate arguments
307
+ for (const value of allSeparateArgs) {
308
+ result += `, '${escapeString(value)}'`;
309
+ }
310
+
311
+ // Check if the last element in the chain has multiple children
312
+ const lastElement = chain[chain.length - 1];
313
+ const children = lastElement.children.filter(child =>
314
+ child.type === 'element' || (child.type === 'text' && child.content.trim())
315
+ );
316
+
317
+ // Exclude the case where there's only text (already handled above)
318
+ const hasOnlyText = children.length === 1 && children[0].type === 'text';
319
+
320
+ if (children.length > 0 && !hasOnlyText) {
321
+ // Add children as callback function
322
+ result += `, () => {\n`;
323
+ for (const child of children) {
324
+ result += processNode(child, indentLevel + 1);
325
+ }
326
+ result += `${indent}}`;
327
+ }
328
+
329
+ result += `);\n`;
330
+ return result;
331
+ }
332
+
333
+ // Get a chain of nodes where each node has exactly one element child
334
+ function getSingleChildChain(node) {
335
+ const chain = [node];
336
+ let current = node;
337
+
338
+ while (true) {
339
+ const elementChildren = current.children.filter(child => child.type === 'element');
340
+
341
+ if (elementChildren.length === 1) {
342
+ current = elementChildren[0];
343
+ chain.push(current);
344
+ } else {
345
+ break;
346
+ }
347
+ }
348
+
349
+ return chain;
350
+ }
351
+
352
+ // Escape special characters for single-quoted strings
353
+ function escapeString(str) {
354
+ return str
355
+ .replace(/\\/g, '\\\\')
356
+ .replace(/'/g, "\\'")
357
+ .replace(/\n/g, '\\n')
358
+ .replace(/\r/g, '\\r')
359
+ .replace(/\t/g, '\\t');
360
+ }
361
+
362
+ // Escape special characters for double-quoted strings within tag strings
363
+ function escapeDoubleQuoted(str) {
364
+ return str
365
+ .replace(/\\/g, '\\\\')
366
+ .replace(/"/g, '\\"')
367
+ .replace(/\n/g, '\\n')
368
+ .replace(/\r/g, '\\r')
369
+ .replace(/\t/g, '\\t');
370
+ }
371
+
372
+ // Build attribute string and collect values that need separate arguments
373
+ function buildAttributeString(attributes) {
374
+ let attrString = '';
375
+ const separateArgs = [];
376
+
377
+ for (const attr of attributes) {
378
+ const value = attr.value;
379
+
380
+ if (value === '') {
381
+ // Boolean attribute
382
+ attrString += ` ${attr.name}`;
383
+ } else if (value.includes('"')) {
384
+ // Contains double quotes - must use separate argument
385
+ attrString += ` ${attr.name}=`;
386
+ separateArgs.push(value);
387
+ } else if (value.includes(' ') || value.includes('\n') || value.includes('\r') || value.includes('\t')) {
388
+ // Contains spaces/whitespace - use double quotes with escaping
389
+ attrString += ` ${attr.name}="${escapeDoubleQuoted(value)}"`;
390
+ } else {
391
+ // Simple value - no quotes needed
392
+ attrString += ` ${attr.name}=${value}`;
393
+ }
394
+ }
395
+
396
+ return { attrString, separateArgs };
397
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aberdeen",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "author": "Frank van Viegen",
5
5
  "main": "dist-min/aberdeen.js",
6
6
  "devDependencies": {
@@ -20,10 +20,10 @@
20
20
  "development": "./dist/route.js",
21
21
  "types": "./dist/route.d.ts"
22
22
  },
23
- "./transition": {
24
- "default": "./dist-min/transition.js",
25
- "development": "./dist/transition.js",
26
- "types": "./dist/transition.d.ts"
23
+ "./transitions": {
24
+ "default": "./dist-min/transitions.js",
25
+ "development": "./dist/transitions.js",
26
+ "types": "./dist/transitions.d.ts"
27
27
  },
28
28
  "./prediction": {
29
29
  "default": "./dist-min/prediction.js",