@metagptx/web-sdk 0.0.56 → 0.0.57
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/dist/plugins.js +1 -1
- package/package.json +1 -1
package/dist/plugins.js
CHANGED
|
@@ -191,7 +191,7 @@ export default function NotFoundPage() {
|
|
|
191
191
|
}
|
|
192
192
|
`;function i(e){for(let t of e)if(r.isJSXAttribute(t)&&r.isJSXIdentifier(t.name,{name:`path`})&&r.isStringLiteral(t.value))return t.value.value}function o(e,t){return e.source.value.includes(t)}function s(e,t){return e.specifiers.some(e=>r.isImportDefaultSpecifier(e)||r.isImportSpecifier(e)?e.local.name===t:!1)}return{name:`vite-plugin-404`,enforce:`pre`,resolveId(e){return e===t||e.startsWith(t)?`\0${t}.tsx`:null},async load(e){if(e===`\0${t}.tsx`){let t=await a(n,e,{loader:`tsx`});return{code:t.code,map:t.map}}return null},transform(n,a){if(a===`\0${t}.tsx`||!a.includes(`App.tsx`)||!a.endsWith(`.tsx`))return null;let c;try{c=e.parse(n,{sourceType:`module`,plugins:[`jsx`,`typescript`]})}catch{return null}let l=!1,u=!1,d=!1,f=-1,p=-1,m=` `;N(c,{ImportDeclaration(e){let t=e.node;o(t,`virtual:404-page`)&&(l=!0),s(t,`NotFoundPage`)&&(u=!0),t.end&&t.end>f&&(f=t.end)},JSXElement(e){let t=e.node.openingElement;if(r.isJSXIdentifier(t.name,{name:`Route`})){let e=i(t.attributes);if(e===`*`&&(d=!0),t.start!==void 0&&t.start!==null){let e=n.lastIndexOf(`
|
|
193
193
|
`,t.start)+1,r=n.substring(e,t.start);/^\s+$/.test(r)&&(m=r)}}if(r.isJSXIdentifier(t.name,{name:`Routes`})){let t=e.node.closingElement;t&&t.start!==void 0&&t.start!==null&&(p=t.start)}}});let h=!l&&!u,g=!d;if(!h&&!g||h&&f===-1)return null;let _=new M(n),v=!1;if(h&&f!==-1){let e=`
|
|
194
|
-
import NotFoundPage from 'virtual:404-page';`;_.appendRight(f,e),v=!0}if(g&&p!==-1){let e=`${m}<Route path="*" element={<NotFoundPage />} />\n`;_.appendLeft(p,e),v=!0}return v?{code:_.toString(),map:_.generateMap({hires:!0})}:null}}}const F=n.default||n;function I(e={}){let{routeFile:n=`src/App.tsx`,entryFile:r=`src/main.tsx`,moduleId:a=`virtual:routes-manifest`,notifyParent:c=!0,messageType:l=`
|
|
194
|
+
import NotFoundPage from 'virtual:404-page';`;_.appendRight(f,e),v=!0}if(g&&p!==-1){let e=`${m}<Route path="*" element={<NotFoundPage />} />\n`;_.appendLeft(p,e),v=!0}return v?{code:_.toString(),map:_.generateMap({hires:!0})}:null}}}const F=n.default||n;function I(e={}){let{routeFile:n=`src/App.tsx`,entryFile:r=`src/main.tsx`,moduleId:a=`virtual:routes-manifest`,notifyParent:c=!0,messageType:l=`routes-manifest`,excludePaths:u=[`*`]}=e,d=`\0${a}`,f=process.cwd();function p(e,t){for(let n of e)if(i.isJSXAttribute(n)&&i.isJSXIdentifier(n.name,{name:t})&&i.isStringLiteral(n.value))return n.value.value}function m(e){for(let t of e)if(i.isJSXAttribute(t)&&i.isJSXIdentifier(t.name,{name:`element`})){let e=t.value;if(i.isJSXExpressionContainer(e)){let t=e.expression;if(i.isJSXElement(t)){let e=t.openingElement;if(i.isJSXIdentifier(e.name))return e.name.name}}}}function h(e){return e.some(e=>i.isJSXAttribute(e)&&i.isJSXIdentifier(e.name,{name:`element`}))}function g(e){return e.some(e=>i.isJSXAttribute(e)&&i.isJSXIdentifier(e.name,{name:`index`}))}function _(e,t){let n=[];for(let r of e)if(i.isJSXElement(r)){let e=r.openingElement;if(i.isJSXIdentifier(e.name,{name:`Route`})){let e=v(r,t);e&&n.push(e)}}return n}function v(e,t){let n=e.openingElement.attributes,r=p(n,`path`),i=g(n),a=h(n),o=m(n),s;if(i)s=t||`/`;else if(r===void 0)return null;else s=r.startsWith(`/`)?r:t===`/`?`/${r}`:`${t}/${r}`;s=s.replace(/\/+/g,`/`),s!==`/`&&s.endsWith(`/`)&&(s=s.slice(0,-1));let c={path:s,hasElement:a,elementName:o,isWildcard:r===`*`,isIndex:i};if(e.children&&e.children.length>0){let t=_(e.children,s);t.length>0&&(c.children=t)}return c}function y(e,t=[]){for(let n of e)n.hasElement&&t.push({path:n.path,elementName:n.elementName}),n.children&&y(n.children,t);return t}function b(e){let t=0;for(let n of e)t++,n.children&&(t+=b(n.children));return t}function x(e){let n={routeTree:[],routes:[],pageCount:0,total:0,generatedAt:new Date().toISOString()};if(!o.existsSync(e))return console.warn(`[routes-scanner] Route file not found: ${e}`),n;let r=o.readFileSync(e,`utf-8`),a;try{a=t.parse(r,{sourceType:`module`,plugins:[`jsx`,`typescript`]})}catch(e){return console.error(`[routes-scanner] Failed to parse route file:`,e),n}let s=[];F(a,{JSXElement(e){let t=e.node.openingElement;if(i.isJSXIdentifier(t.name,{name:`Routes`})){let t=e.node.children;for(let e of t)if(i.isJSXElement(e)){let t=e.openingElement;if(i.isJSXIdentifier(t.name,{name:`Route`})){let t=v(e,``);t&&s.push(t)}}e.stop()}}});let c=y(s),l=c.filter(e=>!u.some(t=>e.path===t||e.path.match(RegExp(`^${t.replace(`*`,`.*`)}$`))));return{routeTree:s,routes:c,pageCount:l.length,total:b(s),generatedAt:new Date().toISOString()}}return{name:`vite-plugin-routes-scanner`,configResolved(e){f=e.root},resolveId(e){if(e===a)return d},load(e){if(e===d){let e=s.resolve(f,n),t=x(e),r=c?`
|
|
195
195
|
// 向父级 iframe 发送路由信息
|
|
196
196
|
function notifyParentWindow() {
|
|
197
197
|
console.log('[routes-scanner] notifyParentWindow', routesManifest);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metagptx/web-sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.57",
|
|
5
5
|
"packageManager": "pnpm@10.15.0+sha512.486ebc259d3e999a4e8691ce03b5cac4a71cbeca39372a9b762cb500cfdf0873e2cb16abe3d951b1ee2cf012503f027b98b6584e4df22524e0c7450d9ec7aa7b",
|
|
6
6
|
"description": "TypeScript SDK for interacting with FuncSea API",
|
|
7
7
|
"author": "MetaGPTX",
|