@oiyo/core 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,183 @@
1
+ oiyo 商业软件许可协议 / oiyo Commercial Software License Agreement
2
+
3
+ 最后更新:2026-04-08
4
+ Last Updated: 2026-04-08
5
+ 作者:skiyee
6
+ Author: skiyee
7
+ 官网:https://oiyo.pages.dev
8
+ Website: https://oiyo.pages.dev
9
+
10
+ 请在安装、复制、分发或使用 OIYO 前,请先阅读本协议。
11
+ PLEASE READ THIS AGREEMENT BEFORE INSTALLING, COPYING, DISTRIBUTING, OR USING OIYO.
12
+
13
+ 安装、复制、分发或使用 OIYO,即表示你同意受本协议约束。
14
+ BY INSTALLING, COPYING, DISTRIBUTING, OR USING OIYO, YOU AGREE TO BE BOUND BY THIS AGREEMENT.
15
+
16
+ 1. 定义 / DEFINITIONS
17
+
18
+ “oiyo” 指由许可方提供的软件包、编译产物、类型定义、文档、示例、发布包及相关材料。
19
+ "oiyo" means the software packages, compiled artifacts, type definitions, documentation, examples, release bundles, and related materials provided by the Licensor.
20
+
21
+ “许可方”指 oiyo 的版权所有人或其授权主体。
22
+ "Licensor" means the copyright owner of oiyo or its authorized entity.
23
+
24
+ “被许可方”指安装、使用、评估或商业化使用 oiyo 的个人、团队或机构。
25
+ "Licensee" means any individual, team, or organization that installs, evaluates, or uses oiyo.
26
+
27
+ 2. 授权范围 / LICENSE GRANT
28
+
29
+ 在遵守本协议及适用商业订单、报价单或企业协议的前提下,许可方授予被许可方一项有限的、不可转让的、不可再许可的、可撤销的使用权,用于:
30
+
31
+ 1) 安装和运行 oiyo 的官方发布版本;
32
+ 2) 在被许可方自身项目中进行内部开发和集成;
33
+ 3) 基于公开文档和示例评估 oiyo 的适用性;
34
+
35
+ Subject to this Agreement and any applicable commercial order or enterprise agreement, the Licensor grants the Licensee a limited, non-transferable, non-sublicensable, revocable license to:
36
+
37
+ 1) install and run officially distributed versions of oiyo.
38
+ 2) use oiyo for internal development and integration in the Licensee's own projects.
39
+ 3) evaluate oiyo based on public documentation and examples.
40
+
41
+ 3. 不授予的权利 / NO RIGHTS GRANTED
42
+
43
+ 除本协议明确授予外,许可方未授予任何其他权利,包括但不限于:
44
+
45
+ 1) 源代码访问权;
46
+ 2) 源代码修改权;
47
+ 3) 再分发权;
48
+ 4) 再销售权;
49
+ 5) 商标使用权;
50
+ 6) 任何未明确授予的知识产权许可;
51
+
52
+ Except as expressly granted in this Agreement, no other rights are granted, including without limitation:
53
+
54
+ 1) access to source code;
55
+ 2) rights to modify source code;
56
+ 3) redistribution rights;
57
+ 4) resale rights;
58
+ 5) trademark rights;
59
+ 6) any intellectual property rights not expressly granted;
60
+
61
+ 4. 使用限制 / RESTRICTIONS
62
+
63
+ 除非法律强制允许或许可方书面同意,被许可方不得:
64
+
65
+ 1) 以源码、半源码、解包产物或其他形式公开、转让、出售或再分发 oiyo;
66
+ 2) 将 oiyo 作为独立产品、框架、模板包或平台能力再次对外销售;
67
+ 3) 冒充官方版本,或以 oiyo 品牌、近似品牌、官方兼容品牌进行商业包装;
68
+ 4) 披露非公开实现细节、内部支持材料、私下交付文档或专有方案;
69
+ 5) 逆向工程、反编译、反汇编、提取或分析受保护的内部实现;
70
+ 6) 将 oiyo 或相关材料用于训练、微调、评估、检索增强或改进任何 AI、LLM 或机器学习系统;
71
+
72
+ Unless expressly permitted by law or in writing by the Licensor, the Licensee may not:
73
+
74
+ 1) publish, transfer, sell, or redistribute oiyo in source, reconstructed, unpacked, or similar form;
75
+ 2) resell oiyo as a standalone framework, toolkit, template package, or platform capability;
76
+ 3) market any fork, derivative, or repackaged offering as an official or confusingly similar oiyo offering;
77
+ 4) disclose non-public implementation details, support materials, private delivery documents, or proprietary solution content;
78
+ 5) reverse engineer, decompile, disassemble, extract, or analyze protected internal implementation details;
79
+ 6) use oiyo or related materials to train, fine-tune, evaluate, retrieve, or improve any AI, LLM, or machine learning system;
80
+
81
+ 5. 试用与商用 / EVALUATION AND COMMERCIAL USE
82
+
83
+ 被许可方可以基于官方安装包、文档和示例进行试用与技术评估。
84
+
85
+ 除另有书面约定外,项目级接入支持、迁移服务、兼容性排查、远程诊断、优先修复、企业群支持、定制开发及其他增值服务,不包含在基础许可中。
86
+
87
+ The Licensee may evaluate oiyo based on official packages, documentation, and examples.
88
+
89
+ Unless otherwise agreed in writing, project onboarding, migration services, compatibility diagnosis, remote troubleshooting, priority fixes, enterprise support channels, custom development, and other value-added services are not included in the base license.
90
+
91
+ 6. 支持边界 / SUPPORT BOUNDARY
92
+
93
+ 免费渠道通常仅用于:
94
+
95
+ 1) 文档与标准用法说明;
96
+ 2) 最小复现下的框架级缺陷反馈;
97
+
98
+ 以下事项属于商业支持范围:
99
+
100
+ 1) 项目接入问题;
101
+ 2) 历史项目迁移;
102
+ 3) uni、vite 或 node 版本兼容问题;
103
+ 4) HMR、构建、转换异常排查;
104
+ 5) 权限、鉴权、中间件、企业方案接入;
105
+ 6) 项目结构治理与定制需求;
106
+
107
+ Free channels are generally limited to:
108
+
109
+ 1) documentation and standard usage guidance;
110
+ 2) reproducible framework-level defect reports with a minimal reproduction;
111
+
112
+ The following are commercial support matters:
113
+
114
+ 1) project onboarding issues;
115
+ 2) migration of existing projects;
116
+ 3) uni, vite, or node compatibility analysis;
117
+ 4) HMR, build, and transformation issue diagnosis;
118
+ 5) auth, permission, middleware, and enterprise solution integration;
119
+ 6) project structure governance and custom requests;
120
+
121
+ 7. 知识产权 / OWNERSHIP
122
+
123
+ oiyo 及其相关文档、发布包、品牌标识、设计方案、实现细节及一切相关知识产权,均归许可方所有。
124
+
125
+ All rights, title, and interest in oiyo, including documentation, release bundles, branding, design, implementation details, and related intellectual property, remain with the Licensor.
126
+
127
+ 8. 商标 / TRADEMARKS
128
+
129
+ 本协议不授予被许可方使用 “oiyo”、相关 logo、项目名称、品牌视觉或其他标识进行产品命名、营销、认证背书或官方化表达的权利。
130
+
131
+ This Agreement does not grant any right to use "oiyo", its logos, project names, visual identity, or related marks for naming, marketing, endorsement, or implying official status.
132
+
133
+ 9. 免责声明 / DISCLAIMER
134
+
135
+ 除非另有书面协议,oiyo 按“现状”提供。许可方不对适销性、特定用途适用性、不中断运行、无错误或特定兼容结果作出明示或默示保证。
136
+
137
+ Unless otherwise agreed in writing, oiyo is provided on an "AS IS" basis without express or implied warranties, including merchantability, fitness for a particular purpose, uninterrupted operation, error-free performance, or compatibility guarantees.
138
+
139
+ 10. 责任限制 / LIMITATION OF LIABILITY
140
+
141
+ 在法律允许的最大范围内,许可方不对任何间接损失、附带损失、特别损失、后果性损失、惩罚性损失、利润损失、收入损失、数据损失或业务中断承担责任;对于未向许可方支付任何费用的被许可方,许可方亦不承担任何赔偿责任。
142
+
143
+ 如因适用法律规定许可方仍需承担责任,许可方在任何情形下的累计责任总额,以被许可方在相关许可或服务下过去 6 个月实际支付给许可方的金额为上限。
144
+
145
+ To the maximum extent permitted by applicable law, the Licensor shall not be liable for any indirect, incidental, special, consequential, punitive, exemplary, lost profits, lost revenue, loss of data, or business interruption damages; and with respect to any Licensee that has paid no fees to the Licensor, the Licensor shall have no liability for any damages, compensation, or other monetary remedies.
146
+
147
+ If, notwithstanding the foregoing, the Licensor is required by applicable law to bear liability, the Licensor's aggregate liability in all circumstances shall not exceed the amount actually paid by the Licensee to the Licensor for the relevant license or services during the preceding 6 months.
148
+
149
+ 11. 协议优先级 / ORDER OF PRECEDENCE
150
+
151
+ 如被许可方与许可方另行签署订单、报价单、企业协议、支持协议或定制开发合同,则该等书面协议优先于本协议。
152
+
153
+ If the Licensee enters into a separate order, quotation, enterprise agreement, support agreement, or custom development contract with the Licensor, such written agreement shall prevail over this Agreement.
154
+
155
+ 12. 第三方组件 / THIRD-PARTY COMPONENTS
156
+
157
+ oiyo 可能依赖、调用、集成或与第三方软件、运行时、SDK、插件、框架或服务协同工作,包括但不限于 uni-app、@dcloudio/*、Vue 及其相关工具。
158
+
159
+ 除 oiyo 自有原创部分外,任何第三方组件的知识产权、许可证和使用限制,均归其各自权利人所有并受其各自协议约束。本协议不授予被许可方任何超出第三方原始许可范围之外的额外权利,也不替代任何第三方协议。
160
+
161
+ 如被许可方使用相关第三方组件,应自行确保其使用方式符合对应的开源许可证、商业条款、平台规则及官方使用要求。
162
+
163
+ oiyo may rely on, call, integrate with, or work alongside third-party software, runtimes, SDKs, plugins, frameworks, or services, including but not limited to uni-app, @dcloudio/*, Vue, and related tooling.
164
+
165
+ Except for oiyo's own original works, the intellectual property rights, licenses, and usage restrictions of any third-party components remain with their respective rights holders and are governed by their own terms. This Agreement does not grant the Licensee any rights beyond the original scope of such third-party licenses, nor does it replace any third-party agreement.
166
+
167
+ If the Licensee uses any such third-party components, the Licensee is solely responsible for ensuring that such use complies with the applicable open-source licenses, commercial terms, platform rules, and official usage requirements.
168
+
169
+ 13. 联系方式 / CONTACT
170
+
171
+ 商业授权、企业支持、再分发授权、合作或品牌使用申请,可通过以下方式联系许可方:
172
+
173
+ 微信/QQ: 319619193
174
+ 邮箱: 319619193@qq.com
175
+ GitHub: https://github.com/skiyee
176
+
177
+ For commercial licensing, enterprise support, redistribution approval, partnership, or trademark use requests, you may contact the Licensor via:
178
+
179
+ WeChat/QQ: 319619193
180
+ Email: 319619193@qq.com
181
+ GitHub: https://github.com/skiyee
182
+
183
+ Copyright (c) 2026 skiyee. All rights reserved.
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # @oiyo/core
2
+
3
+ oiyo 是以融合AI协作、提升开发体验、降低使用心智为目的 UniApp 增强型工程框架
4
+
5
+ ## 仓库
6
+
7
+ - GitHub: `https://github.com/skiyee/oiyo`
8
+ - 问题反馈: `https://github.com/skiyee/oiyo/issues`
9
+
10
+ ### 联系方式
11
+
12
+ - 作者: `skiyee(sKy)`
13
+ - 微信/QQ: `319619193`
14
+ - 邮箱: `319619193@qq.com`
15
+ - GitHub: `https://github.com/skiyee`
16
+
17
+ ## 支持说明
18
+
19
+ oiyo 采用由 oiyo 团队维护的商业发布模式
20
+
21
+ 文档、示例和安装方式公开,oiyo 自有实现源码不公开;项目级接入、迁移、兼容性排查和企业支持由 oiyo 团队提供
22
+
23
+ 免费渠道仅处理可复现的框架级问题;项目级接入、环境兼容、历史项目改造和定制需求属于商业支持范围
24
+
25
+ ## 第三方依赖与许可
26
+
27
+ oiyo 是基于 uni-app 生态的工程增强工具,本项目自有代码适用 oiyo 的商业许可协议
28
+
29
+ oiyo 所依赖、调用或集成的第三方组件与服务,包括但不限于 `uni-app`、`@dcloudio/*`、`Vue` 及其相关工具,仍分别适用其原始许可证、使用协议和权利归属
30
+
31
+ 使用 oiyo 不代表获得第三方组件的额外授权。你在使用相关能力时,仍需自行遵守对应第三方协议与平台要求
32
+
33
+ ## License
34
+
35
+ 本包使用 oiyo 商业软件许可协议。
36
+
37
+ 以下摘要仅用于帮助理解 oiyo 自有代码的授权边界,不替代完整许可文本,第三方组件仍适用其各自原始许可
38
+
39
+ ### 授权范围
40
+
41
+ - 允许安装和运行官方发布版本
42
+ - 允许在自身项目中进行内部开发和集成
43
+ - 允许基于公开文档和示例进行评估
44
+
45
+ ### 不授予的权利
46
+
47
+ - 不授予源代码访问权
48
+ - 不授予源代码修改权
49
+ - 不授予再分发权
50
+ - 不授予再销售权
51
+ - 不授予商标使用权
52
+
53
+ ### 使用限制
54
+
55
+ - 不得公开、转让、出售或再分发源码、半源码或解包产物
56
+ - 不得将 oiyo 作为独立产品、模板包或平台能力再次对外销售
57
+ - 不得冒充官方版本或使用近似品牌进行商业包装
58
+ - 不得披露非公开实现细节、内部支持材料或专有方案
59
+ - 不得逆向工程、反编译、反汇编、提取或分析受保护的内部实现
60
+ - 不得将 oiyo 或相关材料用于训练、微调、评估或改进 AI、LLM 或机器学习系统
61
+
62
+ ### 支持边界
63
+
64
+ - 免费渠道:文档说明、标准用法、最小复现下的框架级缺陷反馈
65
+ - 商业支持:项目接入、历史迁移、兼容性排查、HMR/构建/转换异常、权限与中间件接入、定制需求
66
+
67
+ ### 免责声明与责任限制
68
+
69
+ - 软件按“现状”提供,不承诺适销性、特定用途适用性、不中断运行、无错误或特定兼容结果
70
+ - 在法律允许范围内,许可方不对间接损失、数据损失、利润损失或业务中断承担责任
71
+
72
+ 完整许可条款见仓库根目录与包内 `LICENSE` 文件,第三方组件的许可与使用条件以其各自官方声明为准
@@ -0,0 +1,21 @@
1
+ # Third Party Notices
2
+
3
+ Oiyo may rely on third-party components for runtime, build, framework integration, or developer tooling.
4
+
5
+ ## uni-app / DCloud related packages
6
+
7
+ - Name: `uni-app`, `@dcloudio/*`
8
+ - Provider: DCloud
9
+ - Upstream:
10
+ - `https://github.com/dcloudio/uni-app`
11
+ - `https://uniapp.dcloud.net.cn/license.html`
12
+ - License / Terms:
13
+ - Open-source portions: Apache-2.0
14
+ - Additional usage terms may apply for DCloud-provided runtime, SDK, packaging, and related services
15
+
16
+ ## Vue
17
+
18
+ - Name: `vue`
19
+ - Provider: Vue team
20
+ - Upstream: `https://github.com/vuejs/core`
21
+ - License: MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @oiyo/core v0.0.1
3
+ * Copyright (c) 2026 skiyee. All rights reserved.
4
+ * Commercial software. See LICENSE for terms.
5
+ * Official site: https://oiyo.pages.dev
6
+ */
7
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@oiyo/config`),l=require(`pathe`),u=require(`node:crypto`),d=require(`node:fs`),f=require(`@babel/parser`),p=require(`@babel/traverse`);p=s(p);let m=require(`tinyglobby`),h=require(`node:process`);h=s(h);let g=require(`node:readline`);g=s(g);let _=require(`ansis`),v=require(`node:fs/promises`),y=require(`@vue/compiler-sfc`),ee=require(`c12`),te=require(`defu`),b=require(`magic-string`);b=s(b);let x=require(`fs`),S=require(`fs/promises`),ne=require(`events`),C=require(`path`);C=s(C);let re=require(`node:stream`),w=require(`node:path`),ie=require(`os`);const T=typeof p.default==`function`?p.default:p.default.default;async function ae(e){let{dir:t,extensions:n=[`.*`],exclude:r}=e;if(!(0,d.existsSync)(t))return[];let i=n.map(e=>`**/*${e}`);try{return(await(0,m.glob)(i,{cwd:t,absolute:!0,ignore:r})).map(e=>(0,l.normalize)((0,l.resolve)(e)))}catch(e){return console.error(`[oiyo] Error scanning file:`,e),[]}}function E(e,t=8){return(0,u.createHash)(`sha256`).update(e).digest(`hex`).slice(0,t)}function oe(e,t){let n=`${e}.tmp`;return(0,d.writeFileSync)(n,t,`utf-8`),(0,d.existsSync)(e)&&(0,d.unlinkSync)(e),(0,d.renameSync)(n,e),!0}function se(e){if(!e)return``;let t=e.replace(/\p{Lu}/gu,e=>`-${e.toLowerCase()}`);return t.startsWith(`-`)?t.slice(1):t}function ce(e,t){let n=(0,f.parse)(e,{sourceType:`module`,plugins:[`typescript`]}),r={start:0,end:0};return T(n,{CallExpression(e){let{callee:n,arguments:i}=e.node;n.type===`Identifier`&&n.name===t&&i.length>0&&e.node.start!=null&&e.node.end!=null&&(r.start=e.node.start,r.end=e.node.end,e.stop())}}),r}function le(e){return e.replace(/\s+/g,``)}function ue(e){return e.includes(`<OiyoLayout`)||e.includes(`<oiyo-layout`)}function de(e){let t=e;return t=t.replace(/<OiyoLayout[^>]*?\/>/g,``),t=t.replace(/<OiyoLayout[^>]*>/g,``),t=t.replace(/<\/OiyoLayout>/g,``),t=t.replace(/<oiyo-layout[^>]*?\/>/g,``),t=t.replace(/<oiyo-layout[^>]*>/g,``),t=t.replace(/<\/oiyo-layout>/g,``),t}function fe(e,t){let n=e;return n=n.replace(/<OiyoLayout[^>]*?\/>/g,``),n=n.replace(/<OiyoLayout[^>]*>/g,`<${t}>`),n=n.replace(/<\/OiyoLayout>/g,`</${t}>`),n=n.replace(/<oiyo-layout[^>]*?\/>/g,``),n=n.replace(/<oiyo-layout[^>]*>/g,`<${t}>`),n=n.replace(/<\/oiyo-layout>/g,`</${t}>`),n}function pe(e,t){let{dir:n,name:r}=(0,l.parse)((0,l.relative)(t,e));return(n&&n!==`.`?[...n.split(l.sep),r]:[r]).map(e=>se(e)).join(`-`)}function me(e){return`OiyoLayout${e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}`}var he=class{constructor(e,t){this.config=e,this.layoutFiles=[],this.logger=t.logger.withScope(`LAYOUT`)}get srcDir(){return(0,l.resolve)(this.config.rootDir,this.config.srcDir)}get layoutDir(){return(0,l.resolve)(this.srcDir,this.config.dir?.layouts||`layouts`)}isLayoutPath(e){let t=(0,l.normalize)(e);return!t.endsWith(`.vue`)&&!t.endsWith(`.nvue`)||[...c.DEFAULT_EXCLUDE,...this.config.exclude||[]].some(e=>(0,l.matchesGlob)(t,e))?!1:t.startsWith(`${this.layoutDir}/`)}setLayout(e){if(this.layoutFiles.findIndex(({filePath:t})=>t===e)!==-1)return!1;let t=pe(e,this.layoutDir),n=me(t);return this.layoutFiles.push({useName:t,componentName:n,filePath:e}),!0}async registerLayouts(){let e=await ae({dir:this.layoutDir,extensions:[`.vue`,`.nvue`],exclude:this.config.exclude});return this.layoutFiles=[],e.map(e=>this.setLayout(e)),this.layoutFiles}applyLayout(e,t){if(!ue(t))return{template:t,script:``,imports:[]};if(e===!1)return{template:de(t),script:``,imports:[]};e===void 0&&(e=`default`);let n=this.layoutFiles.find(t=>t.useName===e);return n?{template:fe(t,n.componentName),script:``,imports:[`import ${n.componentName} from '${n.filePath}'`]}:(this.logger.error(`未找到布局 "${e}",请检查布局名称或文件位置是否正确`),{template:t,script:``,imports:[]})}};const D={silent:0,error:1,warn:2,info:3,debug:4,verbose:5};let ge,_e,O=0,ve;function ye(){let e=h.default.stdout.rows-2,t=e>0?`
8
+ `.repeat(e):``;h.default.stdout.write(t),g.default.cursorTo(h.default.stdout,0,0),g.default.clearScreenDown(h.default.stdout)}function be(){return ve??=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`numeric`,second:`numeric`}),ve}function k(e=`info`,t={}){if(t.customLogger)return t.customLogger;let n=new WeakSet,r=new Set,{prefix:i=`[OIYO]`,scope:a,allowClearScreen:o=!0,console:s=globalThis.console}=t,c=D[e],l=o&&h.default.stdout.isTTY&&!h.default.env.CI,u=l?ye:()=>{};function d(e,t,n={}){let r=f(e,n.scope??a);return n.timestamp?`${(0,_.dim)(be().format(new Date))} ${(0,_.blue)(i)} ${r} ${t}`:`${(0,_.blue)((0,_.bold)(i))} ${r} ${t}`}function f(e,t){if(!t)return` `;let n=`[${t.toUpperCase()}]`;return{info:(0,_.cyan)(n),warn:(0,_.yellow)(n),error:(0,_.red)(n),debug:(0,_.dim)((0,_.cyan)(n))}[e]}function p(e,t,r={}){if(c<D[e])return;let i=e;if(r.error&&n.add(r.error),l){if(e===ge&&t===_e){O++,u(),s[e](d(e,t,r),(0,_.yellow)(`(x${O+1})`));return}O=0,ge=e,_e=t,r.clear&&u()}s[i](d(e,t,r))}let m={hasWarned:!1,withScope(n){return k(e,{...t,scope:n})},debug(e,t){p(`debug`,e,t)},info(e,t){p(`info`,e,t)},warn(e,t){m.hasWarned=!0,p(`warn`,e,t)},warnOnce(e,t){r.has(e)||(r.add(e),m.hasWarned=!0,p(`warn`,e,t))},error(e,t){m.hasWarned=!0,p(`error`,e,t)},clearScreen(e){c>=D[e]&&u()},hasErrorLogged(e){return n.has(e)}};return m}function xe(e,t){if(!e.includes(`definePageMeta`))return``;if(!t){let{descriptor:t}=(0,y.parse)(e);if(!t.scriptSetup)return``;e=t.scriptSetup.content}let n=Se(e);return e.substring(n.start,n.end+1).trim()}function Se(e){return ce(e,`definePageMeta`)}function Ce(e){return e.replace(/definePageMeta\s*\(\s*\{[\s\S]*?\}\s*\)/g,``).trim()}function A(e){let t=(0,f.parse)(e,{sourceType:`module`,plugins:[`typescript`]}),n={};return T(t,{CallExpression(e){let{callee:t,arguments:r}=e.node;if(t.type===`Identifier`&&t.name===`definePageMeta`&&r.length>0){let t=r[0];t.type===`ObjectExpression`&&(n=j(t),e.stop())}}}),n}function j(e){let t={};for(let n of e.properties)if(n.type===`ObjectProperty`){let e=we(n.key),r=M(n.value);e&&(t[e]=r)}return t}function we(e){return e.type===`Identifier`?e.name:e.type===`StringLiteral`?e.value:null}function M(e){switch(e.type){case`StringLiteral`:return e.value;case`NumericLiteral`:return e.value;case`BooleanLiteral`:return e.value;case`NullLiteral`:return null;case`ArrayExpression`:return e.elements.map(e=>M(e)).filter(e=>e!==void 0);case`ObjectExpression`:return j(e);default:return}}function Te(e){let t=e.map(e=>({path:e.pagePath,belong:e.pageBelong,...e.pageMeta})),n=[],r=new Map;t.forEach(e=>{if(e.belong===`pages`)n.push(e);else{let t=r.get(e.belong)||[];t.push(e),r.set(e.belong,t)}}),n.sort((e,t)=>{let r=n.find(t=>t.path===e.path)?.type===`home`,i=n.find(e=>e.path===t.path)?.type===`home`;return r&&!i?-1:!r&&i?1:e.path.localeCompare(t.path)});let i={pages:n.map(e=>{let{belong:t,...n}=e;return n})};return r.size>0&&(i.subPackages=Array.from(r.entries()).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({root:e,pages:t.sort((e,t)=>e.path.localeCompare(t.path)).map(e=>{let{belong:t,...n}=e;return n})}))),i}function Ee(e){if(!e||!e.includes(`import`))return[];let t=(0,f.parse)(e,{sourceType:`module`,plugins:[`typescript`]}),n=[];return T(t,{ImportDeclaration(t){let r=e.substring(t.node.start,t.node.end);n.push(r)}}),n}function De(e){if(!e||!e.includes(`import`))return e;let t=(0,f.parse)(e,{sourceType:`module`,plugins:[`typescript`]}),n=[];T(t,{ImportDeclaration(e){n.push({start:e.node.start,end:e.node.end})}}),n.sort((e,t)=>t.start-e.start);let r=e;for(let e of n)r=r.substring(0,e.start)+r.substring(e.end);return r.trim()}function Oe(e,t){let n=N(t),r=N(e);for(let[e,t]of r){let r=n.get(e);r?ke(r,t):n.set(e,t)}return Ae(n)}function N(e){let t=new Map;for(let n of e)T((0,f.parse)(n,{sourceType:`module`,plugins:[`typescript`]}),{ImportDeclaration(e){let{node:r}=e,i=r.source.value,a=t.get(i);a||(a={source:i,named:new Set,original:n},t.set(i,a));for(let e of r.specifiers)if(e.type===`ImportSpecifier`){let t=e.imported.type===`Identifier`?e.imported.name:e.imported.value;a.named.add(t)}else e.type===`ImportDefaultSpecifier`?a.defaultImport=e.local.name:e.type===`ImportNamespaceSpecifier`&&(a.namespaceImport=e.local.name)}});return t}function ke(e,t){for(let n of t.named)e.named.add(n);!e.defaultImport&&t.defaultImport&&(e.defaultImport=t.defaultImport),!e.namespaceImport&&t.namespaceImport&&(e.namespaceImport=t.namespaceImport)}function Ae(e){let t=[];for(let[n,r]of e){if(n.includes(`_fallback_`)){t.push(r.original);continue}let e=[];if(r.defaultImport&&e.push(r.defaultImport),r.namespaceImport&&e.push(`* as ${r.namespaceImport}`),r.named.size>0){let t=Array.from(r.named).sort();e.push(`{ ${t.join(`, `)} }`)}e.length>0?t.push(`import ${e.join(`, `)} from '${n}'`):t.push(`import '${n}'`)}return t}var je=class{constructor(e,t){this.pageFiles=[],this.pagesConfig={},this.config=e,this.logger=t.logger.withScope(`PAGE`),this.oiyoRoot=t.oiyoRoot,this.oiyoLayout=t.oiyoLayout}get srcDir(){return(0,l.resolve)(this.config.rootDir,this.config.srcDir)}get mainPageDir(){return(0,l.resolve)(this.srcDir,this.config.dir.mainPackage)}get subPageDirs(){return this.config.dir.subPackages.map(e=>(0,l.resolve)(this.srcDir,e))}get pagesJsonPath(){return(0,l.resolve)(this.srcDir,`pages.json`)}async loadPagesConfig(){try{let{config:e,configFile:t}=await(0,ee.loadConfig)({name:`pages`,cwd:this.srcDir});this.pagesConfig=e||{}}catch{this.pagesConfig={},this.logger.warn(`加载 pages 配置失败,已采用空配置`)}return this.pagesConfig}async watchPagesConfig(e){if(this.pagesConfigWatcher)return;let t=await(0,ee.watchConfig)({name:`pages`,cwd:this.srcDir,acceptHMR({getDiff:e}){return e().length===0},onWatch:e=>{},onUpdate:({newConfig:t})=>{this.pagesConfig=t.config||{},this.writePagesJson(),e&&Promise.resolve(e()).catch(e=>{this.logger.error(`pages 配置更新回调失败,页面配置已更新但后续回调未完成`,{error:e})})}});this.pagesConfig=t.config||this.pagesConfig,this.pagesConfigWatcher=t}async unwatchPagesConfig(){this.pagesConfigWatcher&&=(await this.pagesConfigWatcher.unwatch(),void 0)}isPagePath(e){let t=(0,l.normalize)(e);return!t.endsWith(`.vue`)&&!t.endsWith(`.nvue`)||[...c.DEFAULT_EXCLUDE,...this.config.exclude||[]].some(e=>(0,l.matchesGlob)(t,e))?!1:[this.mainPageDir,...this.subPageDirs].some(e=>t.startsWith(`${e}/`))}toPageFile(e,t){let n=!0,r=this.mainPageDir,i=this.subPageDirs.find(t=>e.startsWith(`${t}/`));i&&(n=!1);let a=(0,l.parse)((0,l.relative)(n?this.srcDir:i,e)),o=a.dir===``?a.name:(0,l.join)(a.dir,a.name),s=n?r:i;return{filePath:e,pagePath:o,pageBelong:(0,l.relative)(this.srcDir,s),pageMeta:t}}setPageFile(e){let t=this.pageFiles.findIndex(({pagePath:t,pageBelong:n})=>t===e.pagePath&&n===e.pageBelong);if(t===-1)return this.pageFiles.push(e),!0;let n=this.pageFiles[t],r=JSON.stringify(n.pageMeta)!==JSON.stringify(e.pageMeta);return r&&(this.pageFiles[t]=e),r}async loadPagesJson(){try{let e=await(0,v.readFile)(this.pagesJsonPath,`utf-8`),t=JSON.parse(e);for(let e of t.pages||[]){let{path:t,...n}=e,r=(0,l.resolve)(this.srcDir,e.path),i=this.toPageFile(r,n);this.setPageFile(i)}for(let e of t.subPackages||[]){let t=e.root;for(let n of e.pages||[]){let{path:e,...r}=n,i=(0,l.resolve)(this.srcDir,t,n.path);this.setPageFile(this.toPageFile(i,r))}}}catch(e){this.logger.error(`加载 pages.json 失败,已跳过现有文件内容,请检查 pages.json 是否存在且格式正确:`,{error:e})}}writePagesJson(e){try{let t=(0,te.defu)(Te(this.pageFiles),e||this.pagesConfig),n=`${JSON.stringify(t,null,2)}\n`;oe(this.pagesJsonPath,n)}catch(e){this.logger.error(`写入 pages.json 失败,请检查目标文件权限和内容格式:`,{error:e})}}async registerPages(){let e=[this.mainPageDir,...this.subPageDirs],t=(await Promise.all(e.map(e=>ae({dir:e,extensions:[`.vue`,`.nvue`],exclude:this.config.exclude})))).flat(2);for(let e of t){let t=await(0,v.readFile)(e,`utf-8`),n={},r=xe(t);r&&(n=A(r)),this.setPageFile(this.toPageFile(e,n))}return this.pageFiles}async tryUpdatePage(e,t){let n=A(e);this.setPageFile(this.toPageFile(t,n))&&(this.writePagesJson(),await new Promise(e=>setTimeout(e,100)))}async transformPage(e,t){if(!this.oiyoRoot||!this.oiyoLayout)throw Error(`[oiyo] Dependencies are missing; please contact skiyee(319619193@qq.com) to fix them.`);let{descriptor:n}=(0,y.parse)(e),r=new b.default(e);if(!n.template?.content)return{code:r.toString(),sourceMap:r.generateMap()};n.scriptSetup&&await this.tryUpdatePage(n.scriptSetup.content,t);let i=this.oiyoRoot.applyRoot(n),a=[...i.imports],o=i.template,s=i.script,c={};n.scriptSetup&&(c=this.pageFiles.find(e=>t.startsWith(e.filePath))?.pageMeta||{},s=Ce(s));let l=this.oiyoLayout.applyLayout(c.layout,o);if(o=l.template,a.push(...l.imports),r.overwrite(n.template.loc.start.offset,n.template.loc.end.offset,o),n.scriptSetup){let e=Ee(n.scriptSetup.content);a=Oe(a,e),s=De(s),r.overwrite(n.scriptSetup.loc.start.offset,n.scriptSetup.loc.end.offset,`${a.join(`
9
+ `)}\n${s}`)}else if(s||a.length>0){let e=[`<script setup>`,...a,s,`<\/script>`].filter(Boolean).join(`
10
+ `);r.appendRight(n.template.loc.end.offset+11,`\n\n${e}`)}return{code:r.toString(),sourceMap:r.generateMap()}}};const P={FILE_TYPE:`files`,DIR_TYPE:`directories`,FILE_DIR_TYPE:`files_directories`,EVERYTHING_TYPE:`all`},F={root:`.`,fileFilter:e=>!0,directoryFilter:e=>!0,type:P.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(F);const I=`READDIRP_RECURSIVE_ERROR`,Me=new Set([`ENOENT`,`EPERM`,`EACCES`,`ELOOP`,I]),Ne=[P.DIR_TYPE,P.EVERYTHING_TYPE,P.FILE_DIR_TYPE,P.FILE_TYPE],Pe=new Set([P.DIR_TYPE,P.EVERYTHING_TYPE,P.FILE_DIR_TYPE]),Fe=new Set([P.EVERYTHING_TYPE,P.FILE_DIR_TYPE,P.FILE_TYPE]),Ie=e=>Me.has(e.code),Le=process.platform===`win32`,Re=e=>!0,ze=e=>{if(e===void 0)return Re;if(typeof e==`function`)return e;if(typeof e==`string`){let t=e.trim();return e=>e.basename===t}if(Array.isArray(e)){let t=e.map(e=>e.trim());return e=>t.some(t=>e.basename===t)}return Re};var Be=class extends re.Readable{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...F,...e},{root:n,type:r}=t;this._fileFilter=ze(t.fileFilter),this._directoryFilter=ze(t.directoryFilter);let i=t.lstat?v.lstat:v.stat;Le?this._stat=e=>i(e,{bigint:!0}):this._stat=i,this._maxDepth=t.depth??F.depth,this._wantsDir=r?Pe.has(r):!1,this._wantsFile=r?Fe.has(r):!1,this._wantsEverything=r===P.EVERYTHING_TYPE,this._root=(0,w.resolve)(n),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?`dirent`:`stats`,this._rdOptions={encoding:`utf8`,withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let t=this.parent,n=t&&t.files;if(n&&n.length>0){let{path:r,depth:i}=t,a=n.splice(0,e).map(e=>this._formatEntry(e,r)),o=await Promise.all(a);for(let t of o){if(!t)continue;if(this.destroyed)return;let n=await this._getEntryType(t);n===`directory`&&this._directoryFilter(t)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(t.fullPath,i+1)),this._wantsDir&&(this.push(t),e--)):(n===`file`||this._includeAsFile(t))&&this._fileFilter(t)&&this._wantsFile&&(this.push(t),e--)}}else{let e=this.parents.pop();if(!e){this.push(null);break}if(this.parent=await e,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(e,t){let n;try{n=await(0,v.readdir)(e,this._rdOptions)}catch(e){this._onError(e)}return{files:n,depth:t,path:e}}async _formatEntry(e,t){let n,r=this._isDirent?e.name:e;try{let i=(0,w.resolve)((0,w.join)(t,r));n={path:(0,w.relative)(this._root,i),fullPath:i,basename:r},n[this._statsProp]=this._isDirent?e:await this._stat(i)}catch(e){this._onError(e);return}return n}_onError(e){Ie(e)&&!this.destroyed?this.emit(`warn`,e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return``;let t=e[this._statsProp];if(t.isFile())return`file`;if(t.isDirectory())return`directory`;if(t&&t.isSymbolicLink()){let t=e.fullPath;try{let e=await(0,v.realpath)(t),n=await(0,v.lstat)(e);if(n.isFile())return`file`;if(n.isDirectory()){let n=e.length;if(t.startsWith(e)&&t.substr(n,1)===w.sep){let n=Error(`Circular symlink detected: "${t}" points to "${e}"`);return n.code=I,this._onError(n)}return`directory`}}catch(e){return this._onError(e),``}}}_includeAsFile(e){let t=e&&e[this._statsProp];return t&&this._wantsEverything&&!t.isDirectory()}};function Ve(e,t={}){let n=t.entryType||t.type;if(n===`both`&&(n=P.FILE_DIR_TYPE),n&&(t.type=n),!e)throw Error(`readdirp: root argument is required. Usage: readdirp(root, options)`);if(typeof e!=`string`)throw TypeError(`readdirp: root argument must be a string. Usage: readdirp(root, options)`);if(n&&!Ne.includes(n))throw Error(`readdirp: Invalid type passed. Use one of ${Ne.join(`, `)}`);return t.root=e,new Be(t)}const L=()=>{},R=process.platform,He=R===`win32`,Ue=R===`darwin`,We=R===`linux`,Ge=R===`freebsd`,Ke=(0,ie.type)()===`OS400`,z={ALL:`all`,READY:`ready`,ADD:`add`,CHANGE:`change`,ADD_DIR:`addDir`,UNLINK:`unlink`,UNLINK_DIR:`unlinkDir`,RAW:`raw`,ERROR:`error`},B=z,qe={lstat:S.lstat,stat:S.stat},V=`listeners`,H=`errHandlers`,U=`rawEmitters`,Je=[V,H,U],Ye=new Set(`3dm.3ds.3g2.3gp.7z.a.aac.adp.afdesign.afphoto.afpub.ai.aif.aiff.alz.ape.apk.appimage.ar.arj.asf.au.avi.bak.baml.bh.bin.bk.bmp.btif.bz2.bzip2.cab.caf.cgm.class.cmx.cpio.cr2.cur.dat.dcm.deb.dex.djvu.dll.dmg.dng.doc.docm.docx.dot.dotm.dra.DS_Store.dsk.dts.dtshd.dvb.dwg.dxf.ecelp4800.ecelp7470.ecelp9600.egg.eol.eot.epub.exe.f4v.fbs.fh.fla.flac.flatpak.fli.flv.fpx.fst.fvt.g3.gh.gif.graffle.gz.gzip.h261.h263.h264.icns.ico.ief.img.ipa.iso.jar.jpeg.jpg.jpgv.jpm.jxr.key.ktx.lha.lib.lvp.lz.lzh.lzma.lzo.m3u.m4a.m4v.mar.mdi.mht.mid.midi.mj2.mka.mkv.mmr.mng.mobi.mov.movie.mp3.mp4.mp4a.mpeg.mpg.mpga.mxu.nef.npx.numbers.nupkg.o.odp.ods.odt.oga.ogg.ogv.otf.ott.pages.pbm.pcx.pdb.pdf.pea.pgm.pic.png.pnm.pot.potm.potx.ppa.ppam.ppm.pps.ppsm.ppsx.ppt.pptm.pptx.psd.pya.pyc.pyo.pyv.qt.rar.ras.raw.resources.rgb.rip.rlc.rmf.rmvb.rpm.rtf.rz.s3m.s7z.scpt.sgi.shar.snap.sil.sketch.slk.smv.snk.so.stl.suo.sub.swf.tar.tbz.tbz2.tga.tgz.thmx.tif.tiff.tlz.ttc.ttf.txz.udf.uvh.uvi.uvm.uvp.uvs.uvu.viv.vob.war.wav.wax.wbmp.wdp.weba.webm.webp.whl.wim.wm.wma.wmv.wmx.woff.woff2.wrm.wvx.xbm.xif.xla.xlam.xls.xlsb.xlsm.xlsx.xlt.xltm.xltx.xm.xmind.xpi.xpm.xwd.xz.z.zip.zipx`.split(`.`)),Xe=e=>Ye.has(C.extname(e).slice(1).toLowerCase()),W=(e,t)=>{e instanceof Set?e.forEach(t):t(e)},G=(e,t,n)=>{let r=e[t];r instanceof Set||(e[t]=r=new Set([r])),r.add(n)},Ze=e=>t=>{let n=e[t];n instanceof Set?n.clear():delete e[t]},K=(e,t,n)=>{let r=e[t];r instanceof Set?r.delete(n):r===n&&delete e[t]},Qe=e=>e instanceof Set?e.size===0:!e,q=new Map;function $e(e,t,n,r,i){let a=(t,r)=>{n(e),i(t,r,{watchedPath:e}),r&&e!==r&&J(C.resolve(e,r),V,C.join(e,r))};try{return(0,x.watch)(e,{persistent:t.persistent},a)}catch(e){r(e);return}}const J=(e,t,n,r,i)=>{let a=q.get(e);a&&W(a[t],e=>{e(n,r,i)})},et=(e,t,n,r)=>{let{listener:i,errHandler:a,rawEmitter:o}=r,s=q.get(t),c;if(!n.persistent)return c=$e(e,n,i,a,o),c?c.close.bind(c):void 0;if(s)G(s,V,i),G(s,H,a),G(s,U,o);else{if(c=$e(e,n,J.bind(null,t,V),a,J.bind(null,t,U)),!c)return;c.on(B.ERROR,async n=>{let r=J.bind(null,t,H);if(s&&(s.watcherUnusable=!0),He&&n.code===`EPERM`)try{await(await(0,S.open)(e,`r`)).close(),r(n)}catch{}else r(n)}),s={listeners:i,errHandlers:a,rawEmitters:o,watcher:c},q.set(t,s)}return()=>{K(s,V,i),K(s,H,a),K(s,U,o),Qe(s.listeners)&&(s.watcher.close(),q.delete(t),Je.forEach(Ze(s)),s.watcher=void 0,Object.freeze(s))}},Y=new Map,tt=(e,t,n,r)=>{let{listener:i,rawEmitter:a}=r,o=Y.get(t),s=o&&o.options;return s&&(s.persistent<n.persistent||s.interval>n.interval)&&((0,x.unwatchFile)(t),o=void 0),o?(G(o,V,i),G(o,U,a)):(o={listeners:i,rawEmitters:a,options:n,watcher:(0,x.watchFile)(t,n,(n,r)=>{W(o.rawEmitters,e=>{e(B.CHANGE,t,{curr:n,prev:r})});let i=n.mtimeMs;(n.size!==r.size||i>r.mtimeMs||i===0)&&W(o.listeners,t=>t(e,n))})},Y.set(t,o)),()=>{K(o,V,i),K(o,U,a),Qe(o.listeners)&&(Y.delete(t),(0,x.unwatchFile)(t),o.options=o.watcher=void 0,Object.freeze(o))}};var nt=class{constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(e,t){let n=this.fsw.options,r=C.dirname(e),i=C.basename(e);this.fsw._getWatchedDir(r).add(i);let a=C.resolve(e),o={persistent:n.persistent};t||=L;let s;return n.usePolling?(o.interval=n.interval!==n.binaryInterval&&Xe(i)?n.binaryInterval:n.interval,s=tt(e,a,o,{listener:t,rawEmitter:this.fsw._emitRaw})):s=et(e,a,o,{listener:t,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw}),s}_handleFile(e,t,n){if(this.fsw.closed)return;let r=C.dirname(e),i=C.basename(e),a=this.fsw._getWatchedDir(r),o=t;if(a.has(i))return;let s=async(t,n)=>{if(this.fsw._throttle(`watch`,e,5)){if(!n||n.mtimeMs===0)try{let n=await(0,S.stat)(e);if(this.fsw.closed)return;let r=n.atimeMs,i=n.mtimeMs;if((!r||r<=i||i!==o.mtimeMs)&&this.fsw._emit(B.CHANGE,e,n),(Ue||We||Ge)&&o.ino!==n.ino){this.fsw._closeFile(t),o=n;let r=this._watchWithNodeFs(e,s);r&&this.fsw._addPathCloser(t,r)}else o=n}catch{this.fsw._remove(r,i)}else if(a.has(i)){let t=n.atimeMs,r=n.mtimeMs;(!t||t<=r||r!==o.mtimeMs)&&this.fsw._emit(B.CHANGE,e,n),o=n}}},c=this._watchWithNodeFs(e,s);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(B.ADD,e,0))return;this.fsw._emit(B.ADD,e,t)}return c}async _handleSymlink(e,t,n,r){if(this.fsw.closed)return;let i=e.fullPath,a=this.fsw._getWatchedDir(t);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let t;try{t=await(0,S.realpath)(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(i)!==t&&(this.fsw._symlinkPaths.set(i,t),this.fsw._emit(B.CHANGE,n,e.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,t),this.fsw._emit(B.ADD,n,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(e,t,n,r,i,a,o){if(e=C.join(e,``),o=this.fsw._throttle(`readdir`,e,1e3),!o)return;let s=this.fsw._getWatchedDir(n.path),c=new Set,l=this.fsw._readdirp(e,{fileFilter:e=>n.filterPath(e),directoryFilter:e=>n.filterDir(e)});if(l)return l.on(`data`,async o=>{if(this.fsw.closed){l=void 0;return}let u=o.path,d=C.join(e,u);if(c.add(u),!(o.stats.isSymbolicLink()&&await this._handleSymlink(o,e,d,u))){if(this.fsw.closed){l=void 0;return}(u===r||!r&&!s.has(u))&&(this.fsw._incrReadyCount(),d=C.join(i,C.relative(i,d)),this._addToNodeFs(d,t,n,a+1))}}).on(B.ERROR,this._boundHandleError),new Promise((t,u)=>{if(!l)return u();l.once(`end`,()=>{if(this.fsw.closed){l=void 0;return}let u=o?o.clear():!1;t(void 0),s.getChildren().filter(t=>t!==e&&!c.has(t)).forEach(t=>{this.fsw._remove(e,t)}),l=void 0,u&&this._handleRead(e,!1,n,r,i,a,o)})})}async _handleDir(e,t,n,r,i,a,o){let s=this.fsw._getWatchedDir(C.dirname(e)),c=s.has(C.basename(e));!(n&&this.fsw.options.ignoreInitial)&&!i&&!c&&this.fsw._emit(B.ADD_DIR,e,t),s.add(C.basename(e)),this.fsw._getWatchedDir(e);let l,u=this.fsw.options.depth;if((u==null||r<=u)&&!this.fsw._symlinkPaths.has(o)){if(!i&&(await this._handleRead(e,n,a,i,e,r,void 0),this.fsw.closed))return;l=this._watchWithNodeFs(e,(t,n)=>{n&&n.mtimeMs===0||this._handleRead(t,!1,a,i,e,r,void 0)})}return l}async _addToNodeFs(e,t,n,r,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(e);n&&(o.filterPath=e=>n.filterPath(e),o.filterDir=e=>n.filterDir(e));try{let n=await qe[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,n))return a(),!1;let s=this.fsw.options.followSymlinks,c;if(n.isDirectory()){let a=C.resolve(e),l=s?await(0,S.realpath)(e):e;if(this.fsw.closed||(c=await this._handleDir(o.watchPath,n,t,r,i,o,l),this.fsw.closed))return;a!==l&&l!==void 0&&this.fsw._symlinkPaths.set(a,l)}else if(n.isSymbolicLink()){let i=s?await(0,S.realpath)(e):e;if(this.fsw.closed)return;let a=C.dirname(o.watchPath);if(this.fsw._getWatchedDir(a).add(o.watchPath),this.fsw._emit(B.ADD,o.watchPath,n),c=await this._handleDir(a,n,t,r,e,o,i),this.fsw.closed)return;i!==void 0&&this.fsw._symlinkPaths.set(C.resolve(e),i)}else c=this._handleFile(o.watchPath,n,t);return a(),c&&this.fsw._addPathCloser(e,c),!1}catch(t){if(this.fsw._handleError(t))return a(),e}}};
11
+ /*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
12
+ const rt=/\\/g,it=/\/\//,at=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ot=/^\.[/\\]/;function X(e){return Array.isArray(e)?e:[e]}const Z=e=>typeof e==`object`&&!!e&&!(e instanceof RegExp);function st(e){return typeof e==`function`?e:typeof e==`string`?t=>e===t:e instanceof RegExp?t=>e.test(t):typeof e==`object`&&e?t=>{if(e.path===t)return!0;if(e.recursive){let n=C.relative(e.path,t);return n?!n.startsWith(`..`)&&!C.isAbsolute(n):!1}return!1}:()=>!1}function ct(e){if(typeof e!=`string`)throw Error(`string expected`);e=C.normalize(e),e=e.replace(/\\/g,`/`);let t=!1;e.startsWith(`//`)&&(t=!0);let n=/\/\//;for(;e.match(n);)e=e.replace(n,`/`);return t&&(e=`/`+e),e}function lt(e,t,n){let r=ct(t);for(let t=0;t<e.length;t++){let i=e[t];if(i(r,n))return!0}return!1}function ut(e,t){if(e==null)throw TypeError(`anymatch: specify first argument`);let n=X(e).map(e=>st(e));return t==null?(e,t)=>lt(n,e,t):lt(n,t)}const dt=e=>{let t=X(e).flat();if(!t.every(e=>typeof e==`string`))throw TypeError(`Non-string provided as watch path: ${t}`);return t.map(pt)},ft=e=>{let t=e.replace(rt,`/`),n=!1;for(t.startsWith(`//`)&&(n=!0);t.match(it);)t=t.replace(it,`/`);return n&&(t=`/`+t),t},pt=e=>ft(C.normalize(ft(e))),mt=(e=``)=>t=>typeof t==`string`?pt(C.isAbsolute(t)?t:C.join(e,t)):t,ht=(e,t)=>C.isAbsolute(e)?e:C.join(t,e),gt=Object.freeze(new Set);var _t=class{constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==`.`&&e!==`..`&&t.add(e)}async remove(e){let{items:t}=this;if(!t||(t.delete(e),t.size>0))return;let n=this.path;try{await(0,S.readdir)(n)}catch{this._removeWatcher&&this._removeWatcher(C.dirname(n),C.basename(n))}}has(e){let{items:t}=this;if(t)return t.has(e)}getChildren(){let{items:e}=this;return e?[...e.values()]:[]}dispose(){this.items.clear(),this.path=``,this._removeWatcher=L,this.items=gt,Object.freeze(this)}},vt=class{constructor(e,t,n){this.fsw=n;let r=e;this.path=e=e.replace(ot,``),this.watchPath=r,this.fullWatchPath=C.resolve(r),this.dirParts=[],this.dirParts.forEach(e=>{e.length>1&&e.pop()}),this.followSymlinks=t,this.statMethod=t?`stat`:`lstat`}entryPath(e){return C.join(this.watchPath,C.relative(this.watchPath,e.fullPath))}filterPath(e){let{stats:t}=e;if(t&&t.isSymbolicLink())return this.filterDir(e);let n=this.entryPath(e);return this.fsw._isntIgnored(n,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},yt=class extends ne.EventEmitter{constructor(e={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let t=e.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...e,ignored:e.ignored?X(e.ignored):X([]),awaitWriteFinish:t===!0?n:typeof t==`object`?{...n,...t}:!1};Ke&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let e=i.toLowerCase();e===`false`||e===`0`?r.usePolling=!1:e===`true`||e===`1`?r.usePolling=!0:r.usePolling=!!e}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=L,this._readyEmitted=!0,process.nextTick(()=>this.emit(z.READY)))},this._emitRaw=(...e)=>this.emit(z.RAW,...e),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new nt(this),Object.freeze(r)}_addIgnoredPath(e){if(Z(e)){for(let t of this._ignoredPaths)if(Z(t)&&t.path===e.path&&t.recursive===e.recursive)return}this._ignoredPaths.add(e)}_removeIgnoredPath(e){if(this._ignoredPaths.delete(e),typeof e==`string`)for(let t of this._ignoredPaths)Z(t)&&t.path===e&&this._ignoredPaths.delete(t)}add(e,t,n){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let i=dt(e);return r&&(i=i.map(e=>ht(e,r))),i.forEach(e=>{this._removeIgnoredPath(e)}),this._userIgnored=void 0,this._readyCount||=0,this._readyCount+=i.length,Promise.all(i.map(async e=>{let r=await this._nodeFsHandler._addToNodeFs(e,!n,void 0,0,t);return r&&this._emitReady(),r})).then(e=>{this.closed||e.forEach(e=>{e&&this.add(C.dirname(e),C.basename(t||e))})}),this}unwatch(e){if(this.closed)return this;let t=dt(e),{cwd:n}=this.options;return t.forEach(e=>{!C.isAbsolute(e)&&!this._closers.has(e)&&(n&&(e=C.join(n,e)),e=C.resolve(e)),this._closePath(e),this._addIgnoredPath(e),this._watched.has(e)&&this._addIgnoredPath({path:e,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let e=[];return this._closers.forEach(t=>t.forEach(t=>{let n=t();n instanceof Promise&&e.push(n)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=e.length?Promise.all(e).then(()=>void 0):Promise.resolve(),this._closePromise}getWatched(){let e={};return this._watched.forEach((t,n)=>{let r=(this.options.cwd?C.relative(this.options.cwd,n):n)||`.`;e[r]=t.getChildren().sort()}),e}emitWithAll(e,t){this.emit(e,...t),e!==z.ERROR&&this.emit(z.ALL,e,...t)}async _emit(e,t,n){if(this.closed)return;let r=this.options;He&&(t=C.normalize(t)),r.cwd&&(t=C.relative(r.cwd,t));let i=[t];n!=null&&i.push(n);let a=r.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(t)))return o.lastChange=new Date,this;if(r.atomic){if(e===z.UNLINK)return this._pendingUnlinks.set(t,[e,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((e,t)=>{this.emit(...e),this.emit(z.ALL,...e),this._pendingUnlinks.delete(t)})},typeof r.atomic==`number`?r.atomic:100),this;e===z.ADD&&this._pendingUnlinks.has(t)&&(e=z.CHANGE,this._pendingUnlinks.delete(t))}if(a&&(e===z.ADD||e===z.CHANGE)&&this._readyEmitted)return this._awaitWriteFinish(t,a.stabilityThreshold,e,(t,n)=>{t?(e=z.ERROR,i[0]=t,this.emitWithAll(e,i)):n&&(i.length>1?i[1]=n:i.push(n),this.emitWithAll(e,i))}),this;if(e===z.CHANGE&&!this._throttle(z.CHANGE,t,50))return this;if(r.alwaysStat&&n===void 0&&(e===z.ADD||e===z.ADD_DIR||e===z.CHANGE)){let e=r.cwd?C.join(r.cwd,t):t,n;try{n=await(0,S.stat)(e)}catch{}if(!n||this.closed)return;i.push(n)}return this.emitWithAll(e,i),this}_handleError(e){let t=e&&e.code;return e&&t!==`ENOENT`&&t!==`ENOTDIR`&&(!this.options.ignorePermissionErrors||t!==`EPERM`&&t!==`EACCES`)&&this.emit(z.ERROR,e),e||this.closed}_throttle(e,t,n){this._throttled.has(e)||this._throttled.set(e,new Map);let r=this._throttled.get(e);if(!r)throw Error(`invalid throttle`);let i=r.get(t);if(i)return i.count++,!1;let a,o=()=>{let e=r.get(t),n=e?e.count:0;return r.delete(t),clearTimeout(a),e&&clearTimeout(e.timeoutObject),n};a=setTimeout(o,n);let s={timeoutObject:a,clear:o,count:0};return r.set(t,s),s}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,t,n,r){let i=this.options.awaitWriteFinish;if(typeof i!=`object`)return;let a=i.pollInterval,o,s=e;this.options.cwd&&!C.isAbsolute(e)&&(s=C.join(this.options.cwd,e));let c=new Date,l=this._pendingWrites;function u(n){(0,x.stat)(s,(i,s)=>{if(i||!l.has(e)){i&&i.code!==`ENOENT`&&r(i);return}let c=Number(new Date);n&&s.size!==n.size&&(l.get(e).lastChange=c),c-l.get(e).lastChange>=t?(l.delete(e),r(void 0,s)):o=setTimeout(u,a,s)})}l.has(e)||(l.set(e,{lastChange:c,cancelWait:()=>(l.delete(e),clearTimeout(o),n)}),o=setTimeout(u,a))}_isIgnored(e,t){if(this.options.atomic&&at.test(e))return!0;if(!this._userIgnored){let{cwd:e}=this.options,t=(this.options.ignored||[]).map(mt(e));this._userIgnored=ut([...[...this._ignoredPaths].map(mt(e)),...t],void 0)}return this._userIgnored(e,t)}_isntIgnored(e,t){return!this._isIgnored(e,t)}_getWatchHelpers(e){return new vt(e,this.options.followSymlinks,this)}_getWatchedDir(e){let t=C.resolve(e);return this._watched.has(t)||this._watched.set(t,new _t(t,this._boundRemove)),this._watched.get(t)}_hasReadPermissions(e){return this.options.ignorePermissionErrors?!0:!!(Number(e.mode)&256)}_remove(e,t,n){let r=C.join(e,t),i=C.resolve(r);if(n??=this._watched.has(r)||this._watched.has(i),!this._throttle(`remove`,r,100))return;!n&&this._watched.size===1&&this.add(e,t,!0),this._getWatchedDir(r).getChildren().forEach(e=>this._remove(r,e));let a=this._getWatchedDir(e),o=a.has(t);a.remove(t),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let s=r;if(this.options.cwd&&(s=C.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(s)&&this._pendingWrites.get(s).cancelWait()===z.ADD)return;this._watched.delete(r),this._watched.delete(i);let c=n?z.UNLINK_DIR:z.UNLINK;o&&!this._isIgnored(r)&&this._emit(c,r),this._closePath(r)}_closePath(e){this._closeFile(e);let t=C.dirname(e);this._getWatchedDir(t).remove(C.basename(e))}_closeFile(e){let t=this._closers.get(e);t&&(t.forEach(e=>e()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let n=this._closers.get(e);n||(n=[],this._closers.set(e,n)),n.push(t)}_readdirp(e,t){if(this.closed)return;let n=Ve(e,{type:z.ALL,alwaysStat:!0,lstat:!0,...t,depth:0});return this._streams.add(n),n.once(`close`,()=>{n=void 0}),n.once(`end`,()=>{n&&=(this._streams.delete(n),void 0)}),n}};function bt(e,t={}){let n=new yt(t);return n.add(e),n}function xt(e){if(!e.includes(`defineRootContext`))return``;let{descriptor:t}=(0,y.parse)(e);if(!t.scriptSetup)return``;let n=e=t.scriptSetup.content,r=St(n);return n.substring(r.start,r.end+1).trim()}function St(e){return ce(e,`defineRootContext`)}function Ct(e){if(!e.includes(`<template`))return``;let{descriptor:t}=(0,y.parse)(e);return(t.template?.content||``).trim()}function wt(e,t){if(!e)throw Error(`[oiyo] App.vue 必须包含 <template> 节点`);let n=e.content;if(!(n.includes(`<OiyoPage`)||n.includes(`<oiyo-page`)))throw Error(`[oiyo] App.vue 的 template 必须包含 <OiyoPage /> 或 <oiyo-page /> 占位节点`);if(t.varName&&(n=n.replace(RegExp(`\\b${t.varName}\\b`,`g`),`$oiyoRootContext`)),t.varProperties?.length)for(let{local:e,original:r}of t.varProperties)n=n.replace(RegExp(`\\b${e}\\b`,`g`),`$oiyoRootContext.${r}`);return n.trim()}function Tt(e){if(!e)return;let t=e?.content;if(t){let e=Et(t);return e.script?e:void 0}}function Et(e){let t=(0,f.parse)(e,{sourceType:`module`,plugins:[`typescript`]}),n={};return T(t,{ImportDeclaration(t){let r=e.substring(t.node.start,t.node.end);n.imports??=[],n.imports.push(r)},CallExpression(t){let{callee:r,arguments:i}=t.node;if(r.type===`Identifier`&&r.name===`defineRootContext`&&i.length>0){let r=i[0];r.start!=null&&r.end!=null&&(n.script=e.substring(r.start,r.end));let a=t.findParent(e=>e.isVariableDeclarator());if(a&&a.isVariableDeclarator()){let e=a.node.id;e.type===`Identifier`?n.variable=e.name:e.type===`ObjectPattern`&&(n.properties=e.properties.filter(e=>e.type===`ObjectProperty`).map(e=>({original:e.key.type===`Identifier`?e.key.name:String(e.key.value),local:e.value.type===`Identifier`?e.value.name:e.key.name})))}}}}),n}function Dt(e,t){let n=e;return n=n.replace(/<OiyoPage[^>]*?\/>/g,t),n=n.replace(/<OiyoPage[^>]*>\s*<\/OiyoPage>/g,t),n=n.replace(/<oiyo-page[^>]*?\/>/g,t),n=n.replace(/<oiyo-page[^>]*>\s*<\/oiyo-page>/g,t),n}const Ot=`virtual:oiyo-root-context`,Q=`\0${Ot}`;function kt(e){let{script:t,imports:n}=e,r=[];return n?.length&&(r.push(...n),r.push(``)),t?(r.push(`let rootContextInstance = null`),r.push(``),r.push(`export function useRootContext() {`),r.push(`if (!rootContextInstance) {`),r.push(`const factory = ${t}`),r.push(`rootContextInstance = factory()`),r.push(`}`),r.push(`return rootContextInstance`),r.push(`}`)):(r.push(`export function useRootContext() {`),r.push(`return {}`),r.push(`}`)),r.join(`
13
+ `)}var $=class{constructor(e,t){this.config=e,this.rootView={imports:[],template:`<OiyoPage />`,script:``},this.shouldRefreshVM=e=>{let t=``;this.rootMarco&&(t=E(le(`defineRootContext(${this.rootMarco.script})`)));let n=E(le(xt(e)));return t!==n},this.logger=t.logger.withScope(`ROOT`)}get srcDir(){return(0,l.resolve)(this.config.rootDir,this.config.srcDir)}get rootPath(){return(0,l.resolve)(this.srcDir,`App.vue`)}isRootPath(e){return e===this.rootPath}parseRoot(e){let{descriptor:t}=(0,y.parse)(e),n=Tt(t.scriptSetup);return this.rootView={template:wt(t.template,{varName:n?.variable,varProperties:n?.properties}),imports:[],script:``},n&&(this.rootMarco=n,this.rootVM=kt(n),n.script&&(this.rootView.imports.push(`import { useRootContext } from 'virtual:oiyo-root-context'`),this.rootView.script=`const $oiyoRootContext = useRootContext()`)),{view:this.rootView,marco:n}}transformRoot(e){let{descriptor:t}=(0,y.parse)(e),n=new b.default(e);if(t.template){let e=t.template.loc.start.offset-10,r=t.template.loc.end.offset+11;n.remove(e,r)}if(t.scriptSetup){let e=t.scriptSetup.content,r=St(e);if(r.start!==r.end){e.includes(`virtual:oiyo-root-context`)||n.appendLeft(t.scriptSetup.loc.start.offset,`
14
+ import { useRootContext } from 'virtual:oiyo-root-context'
15
+ `);let i=t.scriptSetup.loc.start.offset+r.start,a=t.scriptSetup.loc.start.offset+r.end;i!==a&&n.overwrite(i,a,`useRootContext()`)}}return{code:n.toString(),sourceMap:n.generateMap()}}shouldRefreshView(e){return E(this.rootView.template)!==E(Ct(e))}applyRoot(e){let t=[],n=``,r=``;return e.template&&(n=Dt(this.rootView.template,e.template.content)),e.scriptSetup&&(t.push(...this.rootView.imports),r=`${this.rootView.script}\n${e.scriptSetup.content}`),{imports:t,script:r,template:n}}};function At(e){let t=!1,n=`build`;return e.logger.withScope(`VITE`),[{name:`oiyo:build`,apply:`build`,enforce:`pre`,configResolved(e){n=e.command},async buildStart(){if(t)return;await Promise.all([e.page.loadPagesConfig(),e.page.loadPagesJson(),e.layout.registerLayouts()]);let r=t=>{e.layout.isLayoutPath(t)&&e.layout.registerLayouts()};n===`serve`&&bt(e.layout.layoutDir,{ignoreInitial:!0}).on(`add`,r).on(`unlink`,r),t=!0},async transform(t,n){if(e.root.isRootPath(n))return e.root.parseRoot(t),e.root.transformRoot(t);if(e.page.isPagePath(n))return this.addWatchFile(e.root.rootPath),e.page.transformPage(t,n)},resolveId(e){if(e===`virtual:oiyo-root-context`)return Q},load(t){if(t===Q)return e.root.rootVM||`export function useRootContext() {return {}}`},async closeBundle(){await e.page.unwatchPagesConfig()}}]}function jt(){return[{name:`oiyo:deps`,enforce:`pre`,config(e){return(0,te.defu)(e,{optimizeDeps:{exclude:[`@skiyee/oiyo`]}})}}]}function Mt(e){let t=(0,c.resolveOiyoConfig)(e),n=k();n.withScope(`CONFIG`);let r=new $(t,{logger:n}),i=new he(t,{logger:n});return{logger:n,root:r,layout:i,page:new je(t,{oiyoRoot:r,oiyoLayout:i,logger:n})}}function Nt(e){return e.logger.withScope(`VITE`),e.logger.withScope(`HMR`),[{name:`oiyo:serve`,apply:`serve`,enforce:`pre`,async buildStart(){await Promise.all([e.page.loadPagesConfig(),e.page.loadPagesJson(),e.layout.registerLayouts()])},configureServer(t){e.page.watchPagesConfig(()=>{t.hot.send({type:`full-reload`})});let n=t=>{e.layout.isLayoutPath(t)&&e.layout.registerLayouts()};t.watcher.on(`add`,n),t.watcher.on(`unlink`,n)},async transform(t,n){if(e.root.isRootPath(n))return e.root.parseRoot(t),e.root.transformRoot(t);if(e.page.isPagePath(n))return this.addWatchFile(e.root.rootPath),e.page.transformPage(t,n)},resolveId(e){if(e===`virtual:oiyo-root-context`)return Q},load(t){if(t===Q)return e.root.rootVM||`export function useRootContext() {return {}}`},async handleHotUpdate({file:t,server:n,read:r}){if(e.root.isRootPath(t)){let t=await r(),i=!1;if(e.root.shouldRefreshView(t)&&(i=!0),e.root.shouldRefreshVM(t)){let e=n.moduleGraph.getModuleById(Q);e&&(n.moduleGraph.invalidateModule(e),i=!0)}if(i){n.hot.send({type:`full-reload`});return}}},async closeBundle(){await e.page.unwatchPagesConfig()}}]}function Pt(e={}){let t=Mt(e);return[...jt(),...Nt(t),...At(t)]}exports.LogLevels=D,exports.OiyoCorePlugin=Pt,exports.OiyoLayout=he,exports.OiyoPage=je,exports.OiyoRoot=$,exports.RESOLVED_VIRTUAL_ROOT_CONTEXT_ID=Q,exports.VIRTUAL_ROOT_CONTEXT_ID=Ot,exports.createLogger=k;
@@ -0,0 +1,197 @@
1
+ /**
2
+ * @oiyo/core v0.0.1
3
+ * Copyright (c) 2026 skiyee. All rights reserved.
4
+ * Commercial software. See LICENSE for terms.
5
+ * Official site: https://oiyo.pages.dev
6
+ */
7
+ import { n as PageFile, r as ResolvedPageMeta } from "./types-D6ttx3rg.cjs";
8
+ import { OiyoConfig, PagesConfig } from "@oiyo/config";
9
+ import * as _$magic_string0 from "magic-string";
10
+ import { ConfigWatcher } from "c12";
11
+ import { SFCDescriptor } from "@vue/compiler-sfc";
12
+ import { Plugin } from "vite";
13
+
14
+ //#region src/layout/types.d.ts
15
+ /**
16
+ * 布局信息
17
+ */
18
+ interface LayoutFile {
19
+ /** 布局应用名称 */
20
+ useName: string;
21
+ /** 布局组件名称 */
22
+ componentName: string;
23
+ /** 布局文件的绝对路径 */
24
+ filePath: string;
25
+ }
26
+ //#endregion
27
+ //#region src/logger.d.ts
28
+ type LogType = 'error' | 'warn' | 'info' | 'debug';
29
+ type LogLevel = 'silent' | LogType | 'verbose';
30
+ declare const LogLevels: Record<LogLevel, number>;
31
+ interface LogOptions {
32
+ clear?: boolean;
33
+ timestamp?: boolean;
34
+ scope?: string;
35
+ }
36
+ interface LogErrorOptions extends LogOptions {
37
+ error?: Error | null;
38
+ }
39
+ interface Logger {
40
+ withScope: (scope: string) => Logger;
41
+ debug: (msg: string, options?: LogOptions) => void;
42
+ info: (msg: string, options?: LogOptions) => void;
43
+ warn: (msg: string, options?: LogOptions) => void;
44
+ warnOnce: (msg: string, options?: LogOptions) => void;
45
+ error: (msg: string, options?: LogErrorOptions) => void;
46
+ clearScreen: (type: LogType) => void;
47
+ hasErrorLogged: (error: Error) => boolean;
48
+ hasWarned: boolean;
49
+ }
50
+ interface LoggerOptions {
51
+ prefix?: string;
52
+ scope?: string;
53
+ allowClearScreen?: boolean;
54
+ customLogger?: Logger;
55
+ console?: Console;
56
+ }
57
+ declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger;
58
+ //#endregion
59
+ //#region src/layout/index.d.ts
60
+ declare class OiyoLayout {
61
+ private readonly config;
62
+ layoutFiles: LayoutFile[];
63
+ logger: Logger;
64
+ constructor(config: OiyoConfig, deps: {
65
+ logger: Logger;
66
+ });
67
+ get srcDir(): string;
68
+ get layoutDir(): string;
69
+ isLayoutPath(absPath: string): boolean;
70
+ setLayout(absPath: string): boolean;
71
+ registerLayouts(): Promise<LayoutFile[]>;
72
+ applyLayout(useName: string | false | undefined, template: string): {
73
+ template: string;
74
+ script: string;
75
+ imports: string[];
76
+ };
77
+ }
78
+ //#endregion
79
+ //#region src/root/parse.d.ts
80
+ interface ParsedRootMarco {
81
+ /** 宏引用模块 */
82
+ imports?: string[];
83
+ /** 宏工厂代码 (()=>{xxx}) */
84
+ script?: string;
85
+ /** 宏普通赋值的变量名,如 `const state = defineRootContext(...)` 中的 `state` */
86
+ variable?: string;
87
+ /** 宏解构赋值的属性列表,如 `const { count, user: u } = defineRootContext(...)` */
88
+ properties?: {
89
+ /** 本地变量名(解构后使用的名字) */local: string; /** 原始属性名(对象中的 key) */
90
+ original: string;
91
+ }[];
92
+ }
93
+ //#endregion
94
+ //#region src/root/virtual-module.d.ts
95
+ declare const VIRTUAL_ROOT_CONTEXT_ID = "virtual:oiyo-root-context";
96
+ declare const RESOLVED_VIRTUAL_ROOT_CONTEXT_ID = "\0virtual:oiyo-root-context";
97
+ //#endregion
98
+ //#region src/root/index.d.ts
99
+ interface RootView {
100
+ imports: string[];
101
+ template: string;
102
+ script: string;
103
+ }
104
+ declare class OiyoRoot {
105
+ readonly config: OiyoConfig;
106
+ /** 根视图模块 */
107
+ rootView: RootView;
108
+ /** 根虚拟模块 */
109
+ rootVM?: string;
110
+ /** 根宏命令结构 */
111
+ rootMarco?: ParsedRootMarco;
112
+ /** 日志 */
113
+ logger: Logger;
114
+ constructor(config: OiyoConfig, deps: {
115
+ logger: Logger;
116
+ });
117
+ get srcDir(): string;
118
+ get rootPath(): string;
119
+ isRootPath(absPath: string): boolean;
120
+ parseRoot(source: string): {
121
+ view: RootView;
122
+ marco: ParsedRootMarco | undefined;
123
+ };
124
+ transformRoot(source: string): {
125
+ code: string;
126
+ sourceMap: _$magic_string0.SourceMap;
127
+ };
128
+ shouldRefreshView(code: string): boolean;
129
+ shouldRefreshVM: (code: string) => boolean;
130
+ applyRoot(sfc: SFCDescriptor): {
131
+ imports: string[];
132
+ script: string;
133
+ template: string;
134
+ };
135
+ }
136
+ //#endregion
137
+ //#region src/page/index.d.ts
138
+ declare class OiyoPage {
139
+ pageFiles: PageFile[];
140
+ pagesConfig: PagesConfig;
141
+ pagesConfigWatcher?: ConfigWatcher<PagesConfig>;
142
+ config: OiyoConfig;
143
+ oiyoRoot?: OiyoRoot;
144
+ oiyoLayout?: OiyoLayout;
145
+ logger: Logger;
146
+ constructor(config: OiyoConfig, deps: {
147
+ logger: Logger;
148
+ });
149
+ constructor(config: OiyoConfig, deps: {
150
+ logger: Logger;
151
+ oiyoRoot: OiyoRoot;
152
+ oiyoLayout: OiyoLayout;
153
+ });
154
+ get srcDir(): string;
155
+ get mainPageDir(): string;
156
+ get subPageDirs(): string[];
157
+ get pagesJsonPath(): string;
158
+ loadPagesConfig(): Promise<PagesConfig>;
159
+ watchPagesConfig(onUpdateCallback?: () => void | Promise<void>): Promise<void>;
160
+ unwatchPagesConfig(): Promise<void>;
161
+ /**
162
+ * 检测路径是否属于页面
163
+ */
164
+ isPagePath(absPath: string): boolean;
165
+ toPageFile(filePath: string, pageMeta: ResolvedPageMeta): PageFile;
166
+ /**
167
+ * 设置页面
168
+ * - 支持更新/新增
169
+ * @returns 若需 新增/更新 则返回 true,否则返回 false
170
+ */
171
+ setPageFile(newPage: PageFile): boolean;
172
+ /**
173
+ * 载入 pages.json
174
+ */
175
+ loadPagesJson(): Promise<void>;
176
+ /**
177
+ * 生成并写入 pages.json
178
+ */
179
+ writePagesJson(userPageJson?: PagesConfig): void;
180
+ /**
181
+ * 注册所有页面
182
+ * - 扫描页面
183
+ * - 提取宏命令
184
+ * - 注册页面
185
+ */
186
+ registerPages(): Promise<PageFile[]>;
187
+ tryUpdatePage(scriptContent: string, filePath: string): Promise<void>;
188
+ transformPage(source: string, filePath: string): Promise<{
189
+ code: string;
190
+ sourceMap: _$magic_string0.SourceMap;
191
+ }>;
192
+ }
193
+ //#endregion
194
+ //#region src/plugin/index.d.ts
195
+ declare function OiyoCorePlugin(options?: OiyoConfig): Plugin[];
196
+ //#endregion
197
+ export { LogErrorOptions, LogLevel, LogLevels, LogOptions, LogType, Logger, LoggerOptions, OiyoCorePlugin, OiyoLayout, OiyoPage, OiyoRoot, RESOLVED_VIRTUAL_ROOT_CONTEXT_ID, RootView, VIRTUAL_ROOT_CONTEXT_ID, createLogger };
@@ -0,0 +1,197 @@
1
+ /**
2
+ * @oiyo/core v0.0.1
3
+ * Copyright (c) 2026 skiyee. All rights reserved.
4
+ * Commercial software. See LICENSE for terms.
5
+ * Official site: https://oiyo.pages.dev
6
+ */
7
+ import { n as PageFile, r as ResolvedPageMeta } from "./types-CbY0rJue.mjs";
8
+ import { OiyoConfig, PagesConfig } from "@oiyo/config";
9
+ import { SFCDescriptor } from "@vue/compiler-sfc";
10
+ import { ConfigWatcher } from "c12";
11
+ import * as _$magic_string0 from "magic-string";
12
+ import { Plugin } from "vite";
13
+
14
+ //#region src/layout/types.d.ts
15
+ /**
16
+ * 布局信息
17
+ */
18
+ interface LayoutFile {
19
+ /** 布局应用名称 */
20
+ useName: string;
21
+ /** 布局组件名称 */
22
+ componentName: string;
23
+ /** 布局文件的绝对路径 */
24
+ filePath: string;
25
+ }
26
+ //#endregion
27
+ //#region src/logger.d.ts
28
+ type LogType = 'error' | 'warn' | 'info' | 'debug';
29
+ type LogLevel = 'silent' | LogType | 'verbose';
30
+ declare const LogLevels: Record<LogLevel, number>;
31
+ interface LogOptions {
32
+ clear?: boolean;
33
+ timestamp?: boolean;
34
+ scope?: string;
35
+ }
36
+ interface LogErrorOptions extends LogOptions {
37
+ error?: Error | null;
38
+ }
39
+ interface Logger {
40
+ withScope: (scope: string) => Logger;
41
+ debug: (msg: string, options?: LogOptions) => void;
42
+ info: (msg: string, options?: LogOptions) => void;
43
+ warn: (msg: string, options?: LogOptions) => void;
44
+ warnOnce: (msg: string, options?: LogOptions) => void;
45
+ error: (msg: string, options?: LogErrorOptions) => void;
46
+ clearScreen: (type: LogType) => void;
47
+ hasErrorLogged: (error: Error) => boolean;
48
+ hasWarned: boolean;
49
+ }
50
+ interface LoggerOptions {
51
+ prefix?: string;
52
+ scope?: string;
53
+ allowClearScreen?: boolean;
54
+ customLogger?: Logger;
55
+ console?: Console;
56
+ }
57
+ declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger;
58
+ //#endregion
59
+ //#region src/layout/index.d.ts
60
+ declare class OiyoLayout {
61
+ private readonly config;
62
+ layoutFiles: LayoutFile[];
63
+ logger: Logger;
64
+ constructor(config: OiyoConfig, deps: {
65
+ logger: Logger;
66
+ });
67
+ get srcDir(): string;
68
+ get layoutDir(): string;
69
+ isLayoutPath(absPath: string): boolean;
70
+ setLayout(absPath: string): boolean;
71
+ registerLayouts(): Promise<LayoutFile[]>;
72
+ applyLayout(useName: string | false | undefined, template: string): {
73
+ template: string;
74
+ script: string;
75
+ imports: string[];
76
+ };
77
+ }
78
+ //#endregion
79
+ //#region src/root/parse.d.ts
80
+ interface ParsedRootMarco {
81
+ /** 宏引用模块 */
82
+ imports?: string[];
83
+ /** 宏工厂代码 (()=>{xxx}) */
84
+ script?: string;
85
+ /** 宏普通赋值的变量名,如 `const state = defineRootContext(...)` 中的 `state` */
86
+ variable?: string;
87
+ /** 宏解构赋值的属性列表,如 `const { count, user: u } = defineRootContext(...)` */
88
+ properties?: {
89
+ /** 本地变量名(解构后使用的名字) */local: string; /** 原始属性名(对象中的 key) */
90
+ original: string;
91
+ }[];
92
+ }
93
+ //#endregion
94
+ //#region src/root/virtual-module.d.ts
95
+ declare const VIRTUAL_ROOT_CONTEXT_ID = "virtual:oiyo-root-context";
96
+ declare const RESOLVED_VIRTUAL_ROOT_CONTEXT_ID = "\0virtual:oiyo-root-context";
97
+ //#endregion
98
+ //#region src/root/index.d.ts
99
+ interface RootView {
100
+ imports: string[];
101
+ template: string;
102
+ script: string;
103
+ }
104
+ declare class OiyoRoot {
105
+ readonly config: OiyoConfig;
106
+ /** 根视图模块 */
107
+ rootView: RootView;
108
+ /** 根虚拟模块 */
109
+ rootVM?: string;
110
+ /** 根宏命令结构 */
111
+ rootMarco?: ParsedRootMarco;
112
+ /** 日志 */
113
+ logger: Logger;
114
+ constructor(config: OiyoConfig, deps: {
115
+ logger: Logger;
116
+ });
117
+ get srcDir(): string;
118
+ get rootPath(): string;
119
+ isRootPath(absPath: string): boolean;
120
+ parseRoot(source: string): {
121
+ view: RootView;
122
+ marco: ParsedRootMarco | undefined;
123
+ };
124
+ transformRoot(source: string): {
125
+ code: string;
126
+ sourceMap: _$magic_string0.SourceMap;
127
+ };
128
+ shouldRefreshView(code: string): boolean;
129
+ shouldRefreshVM: (code: string) => boolean;
130
+ applyRoot(sfc: SFCDescriptor): {
131
+ imports: string[];
132
+ script: string;
133
+ template: string;
134
+ };
135
+ }
136
+ //#endregion
137
+ //#region src/page/index.d.ts
138
+ declare class OiyoPage {
139
+ pageFiles: PageFile[];
140
+ pagesConfig: PagesConfig;
141
+ pagesConfigWatcher?: ConfigWatcher<PagesConfig>;
142
+ config: OiyoConfig;
143
+ oiyoRoot?: OiyoRoot;
144
+ oiyoLayout?: OiyoLayout;
145
+ logger: Logger;
146
+ constructor(config: OiyoConfig, deps: {
147
+ logger: Logger;
148
+ });
149
+ constructor(config: OiyoConfig, deps: {
150
+ logger: Logger;
151
+ oiyoRoot: OiyoRoot;
152
+ oiyoLayout: OiyoLayout;
153
+ });
154
+ get srcDir(): string;
155
+ get mainPageDir(): string;
156
+ get subPageDirs(): string[];
157
+ get pagesJsonPath(): string;
158
+ loadPagesConfig(): Promise<PagesConfig>;
159
+ watchPagesConfig(onUpdateCallback?: () => void | Promise<void>): Promise<void>;
160
+ unwatchPagesConfig(): Promise<void>;
161
+ /**
162
+ * 检测路径是否属于页面
163
+ */
164
+ isPagePath(absPath: string): boolean;
165
+ toPageFile(filePath: string, pageMeta: ResolvedPageMeta): PageFile;
166
+ /**
167
+ * 设置页面
168
+ * - 支持更新/新增
169
+ * @returns 若需 新增/更新 则返回 true,否则返回 false
170
+ */
171
+ setPageFile(newPage: PageFile): boolean;
172
+ /**
173
+ * 载入 pages.json
174
+ */
175
+ loadPagesJson(): Promise<void>;
176
+ /**
177
+ * 生成并写入 pages.json
178
+ */
179
+ writePagesJson(userPageJson?: PagesConfig): void;
180
+ /**
181
+ * 注册所有页面
182
+ * - 扫描页面
183
+ * - 提取宏命令
184
+ * - 注册页面
185
+ */
186
+ registerPages(): Promise<PageFile[]>;
187
+ tryUpdatePage(scriptContent: string, filePath: string): Promise<void>;
188
+ transformPage(source: string, filePath: string): Promise<{
189
+ code: string;
190
+ sourceMap: _$magic_string0.SourceMap;
191
+ }>;
192
+ }
193
+ //#endregion
194
+ //#region src/plugin/index.d.ts
195
+ declare function OiyoCorePlugin(options?: OiyoConfig): Plugin[];
196
+ //#endregion
197
+ export { LogErrorOptions, LogLevel, LogLevels, LogOptions, LogType, Logger, LoggerOptions, OiyoCorePlugin, OiyoLayout, OiyoPage, OiyoRoot, RESOLVED_VIRTUAL_ROOT_CONTEXT_ID, RootView, VIRTUAL_ROOT_CONTEXT_ID, createLogger };
package/dist/index.mjs ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @oiyo/core v0.0.1
3
+ * Copyright (c) 2026 skiyee. All rights reserved.
4
+ * Commercial software. See LICENSE for terms.
5
+ * Official site: https://oiyo.pages.dev
6
+ */
7
+ import{DEFAULT_EXCLUDE as e,resolveOiyoConfig as t}from"@oiyo/config";import{join as n,matchesGlob as r,normalize as i,parse as a,relative as o,resolve as s,sep as c}from"pathe";import{createHash as l}from"node:crypto";import{existsSync as u,renameSync as d,unlinkSync as ee,writeFileSync as f}from"node:fs";import{parse as p}from"@babel/parser";import m from"@babel/traverse";import{glob as te}from"tinyglobby";import h from"node:process";import ne from"node:readline";import{blue as re,bold as ie,cyan as ae,dim as oe,red as se,yellow as ce}from"ansis";import{lstat as le,readFile as ue,readdir as de,realpath as fe,stat as pe}from"node:fs/promises";import{parse as g}from"@vue/compiler-sfc";import{loadConfig as me,watchConfig as he}from"c12";import{defu as _}from"defu";import v from"magic-string";import{stat as ge,unwatchFile as y,watch as _e,watchFile as ve}from"fs";import{lstat as ye,open as be,readdir as xe,realpath as b,stat as x}from"fs/promises";import{EventEmitter as Se}from"events";import*as S from"path";import{Readable as Ce}from"node:stream";import{join as we,relative as Te,resolve as Ee,sep as De}from"node:path";import{type as Oe}from"os";const C=typeof m==`function`?m:m.default;async function ke(e){let{dir:t,extensions:n=[`.*`],exclude:r}=e;if(!u(t))return[];let a=n.map(e=>`**/*${e}`);try{return(await te(a,{cwd:t,absolute:!0,ignore:r})).map(e=>i(s(e)))}catch(e){return console.error(`[oiyo] Error scanning file:`,e),[]}}function w(e,t=8){return l(`sha256`).update(e).digest(`hex`).slice(0,t)}function Ae(e,t){let n=`${e}.tmp`;return f(n,t,`utf-8`),u(e)&&ee(e),d(n,e),!0}function je(e){if(!e)return``;let t=e.replace(/\p{Lu}/gu,e=>`-${e.toLowerCase()}`);return t.startsWith(`-`)?t.slice(1):t}function Me(e,t){let n=p(e,{sourceType:`module`,plugins:[`typescript`]}),r={start:0,end:0};return C(n,{CallExpression(e){let{callee:n,arguments:i}=e.node;n.type===`Identifier`&&n.name===t&&i.length>0&&e.node.start!=null&&e.node.end!=null&&(r.start=e.node.start,r.end=e.node.end,e.stop())}}),r}function Ne(e){return e.replace(/\s+/g,``)}function Pe(e){return e.includes(`<OiyoLayout`)||e.includes(`<oiyo-layout`)}function Fe(e){let t=e;return t=t.replace(/<OiyoLayout[^>]*?\/>/g,``),t=t.replace(/<OiyoLayout[^>]*>/g,``),t=t.replace(/<\/OiyoLayout>/g,``),t=t.replace(/<oiyo-layout[^>]*?\/>/g,``),t=t.replace(/<oiyo-layout[^>]*>/g,``),t=t.replace(/<\/oiyo-layout>/g,``),t}function Ie(e,t){let n=e;return n=n.replace(/<OiyoLayout[^>]*?\/>/g,``),n=n.replace(/<OiyoLayout[^>]*>/g,`<${t}>`),n=n.replace(/<\/OiyoLayout>/g,`</${t}>`),n=n.replace(/<oiyo-layout[^>]*?\/>/g,``),n=n.replace(/<oiyo-layout[^>]*>/g,`<${t}>`),n=n.replace(/<\/oiyo-layout>/g,`</${t}>`),n}function Le(e,t){let{dir:n,name:r}=a(o(t,e));return(n&&n!==`.`?[...n.split(c),r]:[r]).map(e=>je(e)).join(`-`)}function Re(e){return`OiyoLayout${e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}`}var ze=class{constructor(e,t){this.config=e,this.layoutFiles=[],this.logger=t.logger.withScope(`LAYOUT`)}get srcDir(){return s(this.config.rootDir,this.config.srcDir)}get layoutDir(){return s(this.srcDir,this.config.dir?.layouts||`layouts`)}isLayoutPath(t){let n=i(t);return!n.endsWith(`.vue`)&&!n.endsWith(`.nvue`)||[...e,...this.config.exclude||[]].some(e=>r(n,e))?!1:n.startsWith(`${this.layoutDir}/`)}setLayout(e){if(this.layoutFiles.findIndex(({filePath:t})=>t===e)!==-1)return!1;let t=Le(e,this.layoutDir),n=Re(t);return this.layoutFiles.push({useName:t,componentName:n,filePath:e}),!0}async registerLayouts(){let e=await ke({dir:this.layoutDir,extensions:[`.vue`,`.nvue`],exclude:this.config.exclude});return this.layoutFiles=[],e.map(e=>this.setLayout(e)),this.layoutFiles}applyLayout(e,t){if(!Pe(t))return{template:t,script:``,imports:[]};if(e===!1)return{template:Fe(t),script:``,imports:[]};e===void 0&&(e=`default`);let n=this.layoutFiles.find(t=>t.useName===e);return n?{template:Ie(t,n.componentName),script:``,imports:[`import ${n.componentName} from '${n.filePath}'`]}:(this.logger.error(`未找到布局 "${e}",请检查布局名称或文件位置是否正确`),{template:t,script:``,imports:[]})}};const T={silent:0,error:1,warn:2,info:3,debug:4,verbose:5};let Be,Ve,E=0,He;function Ue(){let e=h.stdout.rows-2,t=e>0?`
8
+ `.repeat(e):``;h.stdout.write(t),ne.cursorTo(h.stdout,0,0),ne.clearScreenDown(h.stdout)}function We(){return He??=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`numeric`,second:`numeric`}),He}function D(e=`info`,t={}){if(t.customLogger)return t.customLogger;let n=new WeakSet,r=new Set,{prefix:i=`[OIYO]`,scope:a,allowClearScreen:o=!0,console:s=globalThis.console}=t,c=T[e],l=o&&h.stdout.isTTY&&!h.env.CI,u=l?Ue:()=>{};function d(e,t,n={}){let r=ee(e,n.scope??a);return n.timestamp?`${oe(We().format(new Date))} ${re(i)} ${r} ${t}`:`${re(ie(i))} ${r} ${t}`}function ee(e,t){if(!t)return` `;let n=`[${t.toUpperCase()}]`;return{info:ae(n),warn:ce(n),error:se(n),debug:oe(ae(n))}[e]}function f(e,t,r={}){if(c<T[e])return;let i=e;if(r.error&&n.add(r.error),l){if(e===Be&&t===Ve){E++,u(),s[e](d(e,t,r),ce(`(x${E+1})`));return}E=0,Be=e,Ve=t,r.clear&&u()}s[i](d(e,t,r))}let p={hasWarned:!1,withScope(n){return D(e,{...t,scope:n})},debug(e,t){f(`debug`,e,t)},info(e,t){f(`info`,e,t)},warn(e,t){p.hasWarned=!0,f(`warn`,e,t)},warnOnce(e,t){r.has(e)||(r.add(e),p.hasWarned=!0,f(`warn`,e,t))},error(e,t){p.hasWarned=!0,f(`error`,e,t)},clearScreen(e){c>=T[e]&&u()},hasErrorLogged(e){return n.has(e)}};return p}function Ge(e,t){if(!e.includes(`definePageMeta`))return``;if(!t){let{descriptor:t}=g(e);if(!t.scriptSetup)return``;e=t.scriptSetup.content}let n=Ke(e);return e.substring(n.start,n.end+1).trim()}function Ke(e){return Me(e,`definePageMeta`)}function qe(e){return e.replace(/definePageMeta\s*\(\s*\{[\s\S]*?\}\s*\)/g,``).trim()}function Je(e){let t=p(e,{sourceType:`module`,plugins:[`typescript`]}),n={};return C(t,{CallExpression(e){let{callee:t,arguments:r}=e.node;if(t.type===`Identifier`&&t.name===`definePageMeta`&&r.length>0){let t=r[0];t.type===`ObjectExpression`&&(n=Ye(t),e.stop())}}}),n}function Ye(e){let t={};for(let n of e.properties)if(n.type===`ObjectProperty`){let e=Xe(n.key),r=O(n.value);e&&(t[e]=r)}return t}function Xe(e){return e.type===`Identifier`?e.name:e.type===`StringLiteral`?e.value:null}function O(e){switch(e.type){case`StringLiteral`:return e.value;case`NumericLiteral`:return e.value;case`BooleanLiteral`:return e.value;case`NullLiteral`:return null;case`ArrayExpression`:return e.elements.map(e=>O(e)).filter(e=>e!==void 0);case`ObjectExpression`:return Ye(e);default:return}}function Ze(e){let t=e.map(e=>({path:e.pagePath,belong:e.pageBelong,...e.pageMeta})),n=[],r=new Map;t.forEach(e=>{if(e.belong===`pages`)n.push(e);else{let t=r.get(e.belong)||[];t.push(e),r.set(e.belong,t)}}),n.sort((e,t)=>{let r=n.find(t=>t.path===e.path)?.type===`home`,i=n.find(e=>e.path===t.path)?.type===`home`;return r&&!i?-1:!r&&i?1:e.path.localeCompare(t.path)});let i={pages:n.map(e=>{let{belong:t,...n}=e;return n})};return r.size>0&&(i.subPackages=Array.from(r.entries()).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({root:e,pages:t.sort((e,t)=>e.path.localeCompare(t.path)).map(e=>{let{belong:t,...n}=e;return n})}))),i}function Qe(e){if(!e||!e.includes(`import`))return[];let t=p(e,{sourceType:`module`,plugins:[`typescript`]}),n=[];return C(t,{ImportDeclaration(t){let r=e.substring(t.node.start,t.node.end);n.push(r)}}),n}function $e(e){if(!e||!e.includes(`import`))return e;let t=p(e,{sourceType:`module`,plugins:[`typescript`]}),n=[];C(t,{ImportDeclaration(e){n.push({start:e.node.start,end:e.node.end})}}),n.sort((e,t)=>t.start-e.start);let r=e;for(let e of n)r=r.substring(0,e.start)+r.substring(e.end);return r.trim()}function et(e,t){let n=k(t),r=k(e);for(let[e,t]of r){let r=n.get(e);r?tt(r,t):n.set(e,t)}return nt(n)}function k(e){let t=new Map;for(let n of e)C(p(n,{sourceType:`module`,plugins:[`typescript`]}),{ImportDeclaration(e){let{node:r}=e,i=r.source.value,a=t.get(i);a||(a={source:i,named:new Set,original:n},t.set(i,a));for(let e of r.specifiers)if(e.type===`ImportSpecifier`){let t=e.imported.type===`Identifier`?e.imported.name:e.imported.value;a.named.add(t)}else e.type===`ImportDefaultSpecifier`?a.defaultImport=e.local.name:e.type===`ImportNamespaceSpecifier`&&(a.namespaceImport=e.local.name)}});return t}function tt(e,t){for(let n of t.named)e.named.add(n);!e.defaultImport&&t.defaultImport&&(e.defaultImport=t.defaultImport),!e.namespaceImport&&t.namespaceImport&&(e.namespaceImport=t.namespaceImport)}function nt(e){let t=[];for(let[n,r]of e){if(n.includes(`_fallback_`)){t.push(r.original);continue}let e=[];if(r.defaultImport&&e.push(r.defaultImport),r.namespaceImport&&e.push(`* as ${r.namespaceImport}`),r.named.size>0){let t=Array.from(r.named).sort();e.push(`{ ${t.join(`, `)} }`)}e.length>0?t.push(`import ${e.join(`, `)} from '${n}'`):t.push(`import '${n}'`)}return t}var A=class{constructor(e,t){this.pageFiles=[],this.pagesConfig={},this.config=e,this.logger=t.logger.withScope(`PAGE`),this.oiyoRoot=t.oiyoRoot,this.oiyoLayout=t.oiyoLayout}get srcDir(){return s(this.config.rootDir,this.config.srcDir)}get mainPageDir(){return s(this.srcDir,this.config.dir.mainPackage)}get subPageDirs(){return this.config.dir.subPackages.map(e=>s(this.srcDir,e))}get pagesJsonPath(){return s(this.srcDir,`pages.json`)}async loadPagesConfig(){try{let{config:e,configFile:t}=await me({name:`pages`,cwd:this.srcDir});this.pagesConfig=e||{}}catch{this.pagesConfig={},this.logger.warn(`加载 pages 配置失败,已采用空配置`)}return this.pagesConfig}async watchPagesConfig(e){if(this.pagesConfigWatcher)return;let t=await he({name:`pages`,cwd:this.srcDir,acceptHMR({getDiff:e}){return e().length===0},onWatch:e=>{},onUpdate:({newConfig:t})=>{this.pagesConfig=t.config||{},this.writePagesJson(),e&&Promise.resolve(e()).catch(e=>{this.logger.error(`pages 配置更新回调失败,页面配置已更新但后续回调未完成`,{error:e})})}});this.pagesConfig=t.config||this.pagesConfig,this.pagesConfigWatcher=t}async unwatchPagesConfig(){this.pagesConfigWatcher&&=(await this.pagesConfigWatcher.unwatch(),void 0)}isPagePath(t){let n=i(t);return!n.endsWith(`.vue`)&&!n.endsWith(`.nvue`)||[...e,...this.config.exclude||[]].some(e=>r(n,e))?!1:[this.mainPageDir,...this.subPageDirs].some(e=>n.startsWith(`${e}/`))}toPageFile(e,t){let r=!0,i=this.mainPageDir,s=this.subPageDirs.find(t=>e.startsWith(`${t}/`));s&&(r=!1);let c=a(o(r?this.srcDir:s,e)),l=c.dir===``?c.name:n(c.dir,c.name),u=r?i:s;return{filePath:e,pagePath:l,pageBelong:o(this.srcDir,u),pageMeta:t}}setPageFile(e){let t=this.pageFiles.findIndex(({pagePath:t,pageBelong:n})=>t===e.pagePath&&n===e.pageBelong);if(t===-1)return this.pageFiles.push(e),!0;let n=this.pageFiles[t],r=JSON.stringify(n.pageMeta)!==JSON.stringify(e.pageMeta);return r&&(this.pageFiles[t]=e),r}async loadPagesJson(){try{let e=await ue(this.pagesJsonPath,`utf-8`),t=JSON.parse(e);for(let e of t.pages||[]){let{path:t,...n}=e,r=s(this.srcDir,e.path),i=this.toPageFile(r,n);this.setPageFile(i)}for(let e of t.subPackages||[]){let t=e.root;for(let n of e.pages||[]){let{path:e,...r}=n,i=s(this.srcDir,t,n.path);this.setPageFile(this.toPageFile(i,r))}}}catch(e){this.logger.error(`加载 pages.json 失败,已跳过现有文件内容,请检查 pages.json 是否存在且格式正确:`,{error:e})}}writePagesJson(e){try{let t=_(Ze(this.pageFiles),e||this.pagesConfig),n=`${JSON.stringify(t,null,2)}\n`;Ae(this.pagesJsonPath,n)}catch(e){this.logger.error(`写入 pages.json 失败,请检查目标文件权限和内容格式:`,{error:e})}}async registerPages(){let e=[this.mainPageDir,...this.subPageDirs],t=(await Promise.all(e.map(e=>ke({dir:e,extensions:[`.vue`,`.nvue`],exclude:this.config.exclude})))).flat(2);for(let e of t){let t=await ue(e,`utf-8`),n={},r=Ge(t);r&&(n=Je(r)),this.setPageFile(this.toPageFile(e,n))}return this.pageFiles}async tryUpdatePage(e,t){let n=Je(e);this.setPageFile(this.toPageFile(t,n))&&(this.writePagesJson(),await new Promise(e=>setTimeout(e,100)))}async transformPage(e,t){if(!this.oiyoRoot||!this.oiyoLayout)throw Error(`[oiyo] Dependencies are missing; please contact skiyee(319619193@qq.com) to fix them.`);let{descriptor:n}=g(e),r=new v(e);if(!n.template?.content)return{code:r.toString(),sourceMap:r.generateMap()};n.scriptSetup&&await this.tryUpdatePage(n.scriptSetup.content,t);let i=this.oiyoRoot.applyRoot(n),a=[...i.imports],o=i.template,s=i.script,c={};n.scriptSetup&&(c=this.pageFiles.find(e=>t.startsWith(e.filePath))?.pageMeta||{},s=qe(s));let l=this.oiyoLayout.applyLayout(c.layout,o);if(o=l.template,a.push(...l.imports),r.overwrite(n.template.loc.start.offset,n.template.loc.end.offset,o),n.scriptSetup){let e=Qe(n.scriptSetup.content);a=et(a,e),s=$e(s),r.overwrite(n.scriptSetup.loc.start.offset,n.scriptSetup.loc.end.offset,`${a.join(`
9
+ `)}\n${s}`)}else if(s||a.length>0){let e=[`<script setup>`,...a,s,`<\/script>`].filter(Boolean).join(`
10
+ `);r.appendRight(n.template.loc.end.offset+11,`\n\n${e}`)}return{code:r.toString(),sourceMap:r.generateMap()}}};const j={FILE_TYPE:`files`,DIR_TYPE:`directories`,FILE_DIR_TYPE:`files_directories`,EVERYTHING_TYPE:`all`},M={root:`.`,fileFilter:e=>!0,directoryFilter:e=>!0,type:j.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(M);const N=`READDIRP_RECURSIVE_ERROR`,rt=new Set([`ENOENT`,`EPERM`,`EACCES`,`ELOOP`,N]),P=[j.DIR_TYPE,j.EVERYTHING_TYPE,j.FILE_DIR_TYPE,j.FILE_TYPE],it=new Set([j.DIR_TYPE,j.EVERYTHING_TYPE,j.FILE_DIR_TYPE]),at=new Set([j.EVERYTHING_TYPE,j.FILE_DIR_TYPE,j.FILE_TYPE]),ot=e=>rt.has(e.code),st=process.platform===`win32`,F=e=>!0,I=e=>{if(e===void 0)return F;if(typeof e==`function`)return e;if(typeof e==`string`){let t=e.trim();return e=>e.basename===t}if(Array.isArray(e)){let t=e.map(e=>e.trim());return e=>t.some(t=>e.basename===t)}return F};var ct=class extends Ce{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...M,...e},{root:n,type:r}=t;this._fileFilter=I(t.fileFilter),this._directoryFilter=I(t.directoryFilter);let i=t.lstat?le:pe;st?this._stat=e=>i(e,{bigint:!0}):this._stat=i,this._maxDepth=t.depth??M.depth,this._wantsDir=r?it.has(r):!1,this._wantsFile=r?at.has(r):!1,this._wantsEverything=r===j.EVERYTHING_TYPE,this._root=Ee(n),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?`dirent`:`stats`,this._rdOptions={encoding:`utf8`,withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let t=this.parent,n=t&&t.files;if(n&&n.length>0){let{path:r,depth:i}=t,a=n.splice(0,e).map(e=>this._formatEntry(e,r)),o=await Promise.all(a);for(let t of o){if(!t)continue;if(this.destroyed)return;let n=await this._getEntryType(t);n===`directory`&&this._directoryFilter(t)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(t.fullPath,i+1)),this._wantsDir&&(this.push(t),e--)):(n===`file`||this._includeAsFile(t))&&this._fileFilter(t)&&this._wantsFile&&(this.push(t),e--)}}else{let e=this.parents.pop();if(!e){this.push(null);break}if(this.parent=await e,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(e,t){let n;try{n=await de(e,this._rdOptions)}catch(e){this._onError(e)}return{files:n,depth:t,path:e}}async _formatEntry(e,t){let n,r=this._isDirent?e.name:e;try{let i=Ee(we(t,r));n={path:Te(this._root,i),fullPath:i,basename:r},n[this._statsProp]=this._isDirent?e:await this._stat(i)}catch(e){this._onError(e);return}return n}_onError(e){ot(e)&&!this.destroyed?this.emit(`warn`,e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return``;let t=e[this._statsProp];if(t.isFile())return`file`;if(t.isDirectory())return`directory`;if(t&&t.isSymbolicLink()){let t=e.fullPath;try{let e=await fe(t),n=await le(e);if(n.isFile())return`file`;if(n.isDirectory()){let n=e.length;if(t.startsWith(e)&&t.substr(n,1)===De){let n=Error(`Circular symlink detected: "${t}" points to "${e}"`);return n.code=N,this._onError(n)}return`directory`}}catch(e){return this._onError(e),``}}}_includeAsFile(e){let t=e&&e[this._statsProp];return t&&this._wantsEverything&&!t.isDirectory()}};function lt(e,t={}){let n=t.entryType||t.type;if(n===`both`&&(n=j.FILE_DIR_TYPE),n&&(t.type=n),!e)throw Error(`readdirp: root argument is required. Usage: readdirp(root, options)`);if(typeof e!=`string`)throw TypeError(`readdirp: root argument must be a string. Usage: readdirp(root, options)`);if(n&&!P.includes(n))throw Error(`readdirp: Invalid type passed. Use one of ${P.join(`, `)}`);return t.root=e,new ct(t)}const L=()=>{},R=process.platform,ut=R===`win32`,dt=R===`darwin`,ft=R===`linux`,pt=R===`freebsd`,mt=Oe()===`OS400`,z={ALL:`all`,READY:`ready`,ADD:`add`,CHANGE:`change`,ADD_DIR:`addDir`,UNLINK:`unlink`,UNLINK_DIR:`unlinkDir`,RAW:`raw`,ERROR:`error`},B=z,ht={lstat:ye,stat:x},V=`listeners`,H=`errHandlers`,U=`rawEmitters`,gt=[V,H,U],_t=new Set(`3dm.3ds.3g2.3gp.7z.a.aac.adp.afdesign.afphoto.afpub.ai.aif.aiff.alz.ape.apk.appimage.ar.arj.asf.au.avi.bak.baml.bh.bin.bk.bmp.btif.bz2.bzip2.cab.caf.cgm.class.cmx.cpio.cr2.cur.dat.dcm.deb.dex.djvu.dll.dmg.dng.doc.docm.docx.dot.dotm.dra.DS_Store.dsk.dts.dtshd.dvb.dwg.dxf.ecelp4800.ecelp7470.ecelp9600.egg.eol.eot.epub.exe.f4v.fbs.fh.fla.flac.flatpak.fli.flv.fpx.fst.fvt.g3.gh.gif.graffle.gz.gzip.h261.h263.h264.icns.ico.ief.img.ipa.iso.jar.jpeg.jpg.jpgv.jpm.jxr.key.ktx.lha.lib.lvp.lz.lzh.lzma.lzo.m3u.m4a.m4v.mar.mdi.mht.mid.midi.mj2.mka.mkv.mmr.mng.mobi.mov.movie.mp3.mp4.mp4a.mpeg.mpg.mpga.mxu.nef.npx.numbers.nupkg.o.odp.ods.odt.oga.ogg.ogv.otf.ott.pages.pbm.pcx.pdb.pdf.pea.pgm.pic.png.pnm.pot.potm.potx.ppa.ppam.ppm.pps.ppsm.ppsx.ppt.pptm.pptx.psd.pya.pyc.pyo.pyv.qt.rar.ras.raw.resources.rgb.rip.rlc.rmf.rmvb.rpm.rtf.rz.s3m.s7z.scpt.sgi.shar.snap.sil.sketch.slk.smv.snk.so.stl.suo.sub.swf.tar.tbz.tbz2.tga.tgz.thmx.tif.tiff.tlz.ttc.ttf.txz.udf.uvh.uvi.uvm.uvp.uvs.uvu.viv.vob.war.wav.wax.wbmp.wdp.weba.webm.webp.whl.wim.wm.wma.wmv.wmx.woff.woff2.wrm.wvx.xbm.xif.xla.xlam.xls.xlsb.xlsm.xlsx.xlt.xltm.xltx.xm.xmind.xpi.xpm.xwd.xz.z.zip.zipx`.split(`.`)),vt=e=>_t.has(S.extname(e).slice(1).toLowerCase()),W=(e,t)=>{e instanceof Set?e.forEach(t):t(e)},G=(e,t,n)=>{let r=e[t];r instanceof Set||(e[t]=r=new Set([r])),r.add(n)},yt=e=>t=>{let n=e[t];n instanceof Set?n.clear():delete e[t]},K=(e,t,n)=>{let r=e[t];r instanceof Set?r.delete(n):r===n&&delete e[t]},bt=e=>e instanceof Set?e.size===0:!e,q=new Map;function xt(e,t,n,r,i){let a=(t,r)=>{n(e),i(t,r,{watchedPath:e}),r&&e!==r&&J(S.resolve(e,r),V,S.join(e,r))};try{return _e(e,{persistent:t.persistent},a)}catch(e){r(e);return}}const J=(e,t,n,r,i)=>{let a=q.get(e);a&&W(a[t],e=>{e(n,r,i)})},St=(e,t,n,r)=>{let{listener:i,errHandler:a,rawEmitter:o}=r,s=q.get(t),c;if(!n.persistent)return c=xt(e,n,i,a,o),c?c.close.bind(c):void 0;if(s)G(s,V,i),G(s,H,a),G(s,U,o);else{if(c=xt(e,n,J.bind(null,t,V),a,J.bind(null,t,U)),!c)return;c.on(B.ERROR,async n=>{let r=J.bind(null,t,H);if(s&&(s.watcherUnusable=!0),ut&&n.code===`EPERM`)try{await(await be(e,`r`)).close(),r(n)}catch{}else r(n)}),s={listeners:i,errHandlers:a,rawEmitters:o,watcher:c},q.set(t,s)}return()=>{K(s,V,i),K(s,H,a),K(s,U,o),bt(s.listeners)&&(s.watcher.close(),q.delete(t),gt.forEach(yt(s)),s.watcher=void 0,Object.freeze(s))}},Y=new Map,Ct=(e,t,n,r)=>{let{listener:i,rawEmitter:a}=r,o=Y.get(t),s=o&&o.options;return s&&(s.persistent<n.persistent||s.interval>n.interval)&&(y(t),o=void 0),o?(G(o,V,i),G(o,U,a)):(o={listeners:i,rawEmitters:a,options:n,watcher:ve(t,n,(n,r)=>{W(o.rawEmitters,e=>{e(B.CHANGE,t,{curr:n,prev:r})});let i=n.mtimeMs;(n.size!==r.size||i>r.mtimeMs||i===0)&&W(o.listeners,t=>t(e,n))})},Y.set(t,o)),()=>{K(o,V,i),K(o,U,a),bt(o.listeners)&&(Y.delete(t),y(t),o.options=o.watcher=void 0,Object.freeze(o))}};var wt=class{constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(e,t){let n=this.fsw.options,r=S.dirname(e),i=S.basename(e);this.fsw._getWatchedDir(r).add(i);let a=S.resolve(e),o={persistent:n.persistent};t||=L;let s;return n.usePolling?(o.interval=n.interval!==n.binaryInterval&&vt(i)?n.binaryInterval:n.interval,s=Ct(e,a,o,{listener:t,rawEmitter:this.fsw._emitRaw})):s=St(e,a,o,{listener:t,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw}),s}_handleFile(e,t,n){if(this.fsw.closed)return;let r=S.dirname(e),i=S.basename(e),a=this.fsw._getWatchedDir(r),o=t;if(a.has(i))return;let s=async(t,n)=>{if(this.fsw._throttle(`watch`,e,5)){if(!n||n.mtimeMs===0)try{let n=await x(e);if(this.fsw.closed)return;let r=n.atimeMs,i=n.mtimeMs;if((!r||r<=i||i!==o.mtimeMs)&&this.fsw._emit(B.CHANGE,e,n),(dt||ft||pt)&&o.ino!==n.ino){this.fsw._closeFile(t),o=n;let r=this._watchWithNodeFs(e,s);r&&this.fsw._addPathCloser(t,r)}else o=n}catch{this.fsw._remove(r,i)}else if(a.has(i)){let t=n.atimeMs,r=n.mtimeMs;(!t||t<=r||r!==o.mtimeMs)&&this.fsw._emit(B.CHANGE,e,n),o=n}}},c=this._watchWithNodeFs(e,s);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(B.ADD,e,0))return;this.fsw._emit(B.ADD,e,t)}return c}async _handleSymlink(e,t,n,r){if(this.fsw.closed)return;let i=e.fullPath,a=this.fsw._getWatchedDir(t);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let t;try{t=await b(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(i)!==t&&(this.fsw._symlinkPaths.set(i,t),this.fsw._emit(B.CHANGE,n,e.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,t),this.fsw._emit(B.ADD,n,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(e,t,n,r,i,a,o){if(e=S.join(e,``),o=this.fsw._throttle(`readdir`,e,1e3),!o)return;let s=this.fsw._getWatchedDir(n.path),c=new Set,l=this.fsw._readdirp(e,{fileFilter:e=>n.filterPath(e),directoryFilter:e=>n.filterDir(e)});if(l)return l.on(`data`,async o=>{if(this.fsw.closed){l=void 0;return}let u=o.path,d=S.join(e,u);if(c.add(u),!(o.stats.isSymbolicLink()&&await this._handleSymlink(o,e,d,u))){if(this.fsw.closed){l=void 0;return}(u===r||!r&&!s.has(u))&&(this.fsw._incrReadyCount(),d=S.join(i,S.relative(i,d)),this._addToNodeFs(d,t,n,a+1))}}).on(B.ERROR,this._boundHandleError),new Promise((t,u)=>{if(!l)return u();l.once(`end`,()=>{if(this.fsw.closed){l=void 0;return}let u=o?o.clear():!1;t(void 0),s.getChildren().filter(t=>t!==e&&!c.has(t)).forEach(t=>{this.fsw._remove(e,t)}),l=void 0,u&&this._handleRead(e,!1,n,r,i,a,o)})})}async _handleDir(e,t,n,r,i,a,o){let s=this.fsw._getWatchedDir(S.dirname(e)),c=s.has(S.basename(e));!(n&&this.fsw.options.ignoreInitial)&&!i&&!c&&this.fsw._emit(B.ADD_DIR,e,t),s.add(S.basename(e)),this.fsw._getWatchedDir(e);let l,u=this.fsw.options.depth;if((u==null||r<=u)&&!this.fsw._symlinkPaths.has(o)){if(!i&&(await this._handleRead(e,n,a,i,e,r,void 0),this.fsw.closed))return;l=this._watchWithNodeFs(e,(t,n)=>{n&&n.mtimeMs===0||this._handleRead(t,!1,a,i,e,r,void 0)})}return l}async _addToNodeFs(e,t,n,r,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(e);n&&(o.filterPath=e=>n.filterPath(e),o.filterDir=e=>n.filterDir(e));try{let n=await ht[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,n))return a(),!1;let s=this.fsw.options.followSymlinks,c;if(n.isDirectory()){let a=S.resolve(e),l=s?await b(e):e;if(this.fsw.closed||(c=await this._handleDir(o.watchPath,n,t,r,i,o,l),this.fsw.closed))return;a!==l&&l!==void 0&&this.fsw._symlinkPaths.set(a,l)}else if(n.isSymbolicLink()){let i=s?await b(e):e;if(this.fsw.closed)return;let a=S.dirname(o.watchPath);if(this.fsw._getWatchedDir(a).add(o.watchPath),this.fsw._emit(B.ADD,o.watchPath,n),c=await this._handleDir(a,n,t,r,e,o,i),this.fsw.closed)return;i!==void 0&&this.fsw._symlinkPaths.set(S.resolve(e),i)}else c=this._handleFile(o.watchPath,n,t);return a(),c&&this.fsw._addPathCloser(e,c),!1}catch(t){if(this.fsw._handleError(t))return a(),e}}};
11
+ /*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
12
+ const Tt=/\\/g,Et=/\/\//,Dt=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,Ot=/^\.[/\\]/;function X(e){return Array.isArray(e)?e:[e]}const Z=e=>typeof e==`object`&&!!e&&!(e instanceof RegExp);function kt(e){return typeof e==`function`?e:typeof e==`string`?t=>e===t:e instanceof RegExp?t=>e.test(t):typeof e==`object`&&e?t=>{if(e.path===t)return!0;if(e.recursive){let n=S.relative(e.path,t);return n?!n.startsWith(`..`)&&!S.isAbsolute(n):!1}return!1}:()=>!1}function At(e){if(typeof e!=`string`)throw Error(`string expected`);e=S.normalize(e),e=e.replace(/\\/g,`/`);let t=!1;e.startsWith(`//`)&&(t=!0);let n=/\/\//;for(;e.match(n);)e=e.replace(n,`/`);return t&&(e=`/`+e),e}function jt(e,t,n){let r=At(t);for(let t=0;t<e.length;t++){let i=e[t];if(i(r,n))return!0}return!1}function Mt(e,t){if(e==null)throw TypeError(`anymatch: specify first argument`);let n=X(e).map(e=>kt(e));return t==null?(e,t)=>jt(n,e,t):jt(n,t)}const Q=e=>{let t=X(e).flat();if(!t.every(e=>typeof e==`string`))throw TypeError(`Non-string provided as watch path: ${t}`);return t.map(Pt)},Nt=e=>{let t=e.replace(Tt,`/`),n=!1;for(t.startsWith(`//`)&&(n=!0);t.match(Et);)t=t.replace(Et,`/`);return n&&(t=`/`+t),t},Pt=e=>Nt(S.normalize(Nt(e))),Ft=(e=``)=>t=>typeof t==`string`?Pt(S.isAbsolute(t)?t:S.join(e,t)):t,It=(e,t)=>S.isAbsolute(e)?e:S.join(t,e),Lt=Object.freeze(new Set);var Rt=class{constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==`.`&&e!==`..`&&t.add(e)}async remove(e){let{items:t}=this;if(!t||(t.delete(e),t.size>0))return;let n=this.path;try{await xe(n)}catch{this._removeWatcher&&this._removeWatcher(S.dirname(n),S.basename(n))}}has(e){let{items:t}=this;if(t)return t.has(e)}getChildren(){let{items:e}=this;return e?[...e.values()]:[]}dispose(){this.items.clear(),this.path=``,this._removeWatcher=L,this.items=Lt,Object.freeze(this)}},zt=class{constructor(e,t,n){this.fsw=n;let r=e;this.path=e=e.replace(Ot,``),this.watchPath=r,this.fullWatchPath=S.resolve(r),this.dirParts=[],this.dirParts.forEach(e=>{e.length>1&&e.pop()}),this.followSymlinks=t,this.statMethod=t?`stat`:`lstat`}entryPath(e){return S.join(this.watchPath,S.relative(this.watchPath,e.fullPath))}filterPath(e){let{stats:t}=e;if(t&&t.isSymbolicLink())return this.filterDir(e);let n=this.entryPath(e);return this.fsw._isntIgnored(n,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},Bt=class extends Se{constructor(e={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let t=e.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...e,ignored:e.ignored?X(e.ignored):X([]),awaitWriteFinish:t===!0?n:typeof t==`object`?{...n,...t}:!1};mt&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let e=i.toLowerCase();e===`false`||e===`0`?r.usePolling=!1:e===`true`||e===`1`?r.usePolling=!0:r.usePolling=!!e}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=L,this._readyEmitted=!0,process.nextTick(()=>this.emit(z.READY)))},this._emitRaw=(...e)=>this.emit(z.RAW,...e),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new wt(this),Object.freeze(r)}_addIgnoredPath(e){if(Z(e)){for(let t of this._ignoredPaths)if(Z(t)&&t.path===e.path&&t.recursive===e.recursive)return}this._ignoredPaths.add(e)}_removeIgnoredPath(e){if(this._ignoredPaths.delete(e),typeof e==`string`)for(let t of this._ignoredPaths)Z(t)&&t.path===e&&this._ignoredPaths.delete(t)}add(e,t,n){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let i=Q(e);return r&&(i=i.map(e=>It(e,r))),i.forEach(e=>{this._removeIgnoredPath(e)}),this._userIgnored=void 0,this._readyCount||=0,this._readyCount+=i.length,Promise.all(i.map(async e=>{let r=await this._nodeFsHandler._addToNodeFs(e,!n,void 0,0,t);return r&&this._emitReady(),r})).then(e=>{this.closed||e.forEach(e=>{e&&this.add(S.dirname(e),S.basename(t||e))})}),this}unwatch(e){if(this.closed)return this;let t=Q(e),{cwd:n}=this.options;return t.forEach(e=>{!S.isAbsolute(e)&&!this._closers.has(e)&&(n&&(e=S.join(n,e)),e=S.resolve(e)),this._closePath(e),this._addIgnoredPath(e),this._watched.has(e)&&this._addIgnoredPath({path:e,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let e=[];return this._closers.forEach(t=>t.forEach(t=>{let n=t();n instanceof Promise&&e.push(n)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=e.length?Promise.all(e).then(()=>void 0):Promise.resolve(),this._closePromise}getWatched(){let e={};return this._watched.forEach((t,n)=>{let r=(this.options.cwd?S.relative(this.options.cwd,n):n)||`.`;e[r]=t.getChildren().sort()}),e}emitWithAll(e,t){this.emit(e,...t),e!==z.ERROR&&this.emit(z.ALL,e,...t)}async _emit(e,t,n){if(this.closed)return;let r=this.options;ut&&(t=S.normalize(t)),r.cwd&&(t=S.relative(r.cwd,t));let i=[t];n!=null&&i.push(n);let a=r.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(t)))return o.lastChange=new Date,this;if(r.atomic){if(e===z.UNLINK)return this._pendingUnlinks.set(t,[e,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((e,t)=>{this.emit(...e),this.emit(z.ALL,...e),this._pendingUnlinks.delete(t)})},typeof r.atomic==`number`?r.atomic:100),this;e===z.ADD&&this._pendingUnlinks.has(t)&&(e=z.CHANGE,this._pendingUnlinks.delete(t))}if(a&&(e===z.ADD||e===z.CHANGE)&&this._readyEmitted)return this._awaitWriteFinish(t,a.stabilityThreshold,e,(t,n)=>{t?(e=z.ERROR,i[0]=t,this.emitWithAll(e,i)):n&&(i.length>1?i[1]=n:i.push(n),this.emitWithAll(e,i))}),this;if(e===z.CHANGE&&!this._throttle(z.CHANGE,t,50))return this;if(r.alwaysStat&&n===void 0&&(e===z.ADD||e===z.ADD_DIR||e===z.CHANGE)){let e=r.cwd?S.join(r.cwd,t):t,n;try{n=await x(e)}catch{}if(!n||this.closed)return;i.push(n)}return this.emitWithAll(e,i),this}_handleError(e){let t=e&&e.code;return e&&t!==`ENOENT`&&t!==`ENOTDIR`&&(!this.options.ignorePermissionErrors||t!==`EPERM`&&t!==`EACCES`)&&this.emit(z.ERROR,e),e||this.closed}_throttle(e,t,n){this._throttled.has(e)||this._throttled.set(e,new Map);let r=this._throttled.get(e);if(!r)throw Error(`invalid throttle`);let i=r.get(t);if(i)return i.count++,!1;let a,o=()=>{let e=r.get(t),n=e?e.count:0;return r.delete(t),clearTimeout(a),e&&clearTimeout(e.timeoutObject),n};a=setTimeout(o,n);let s={timeoutObject:a,clear:o,count:0};return r.set(t,s),s}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,t,n,r){let i=this.options.awaitWriteFinish;if(typeof i!=`object`)return;let a=i.pollInterval,o,s=e;this.options.cwd&&!S.isAbsolute(e)&&(s=S.join(this.options.cwd,e));let c=new Date,l=this._pendingWrites;function u(n){ge(s,(i,s)=>{if(i||!l.has(e)){i&&i.code!==`ENOENT`&&r(i);return}let c=Number(new Date);n&&s.size!==n.size&&(l.get(e).lastChange=c),c-l.get(e).lastChange>=t?(l.delete(e),r(void 0,s)):o=setTimeout(u,a,s)})}l.has(e)||(l.set(e,{lastChange:c,cancelWait:()=>(l.delete(e),clearTimeout(o),n)}),o=setTimeout(u,a))}_isIgnored(e,t){if(this.options.atomic&&Dt.test(e))return!0;if(!this._userIgnored){let{cwd:e}=this.options,t=(this.options.ignored||[]).map(Ft(e));this._userIgnored=Mt([...[...this._ignoredPaths].map(Ft(e)),...t],void 0)}return this._userIgnored(e,t)}_isntIgnored(e,t){return!this._isIgnored(e,t)}_getWatchHelpers(e){return new zt(e,this.options.followSymlinks,this)}_getWatchedDir(e){let t=S.resolve(e);return this._watched.has(t)||this._watched.set(t,new Rt(t,this._boundRemove)),this._watched.get(t)}_hasReadPermissions(e){return this.options.ignorePermissionErrors?!0:!!(Number(e.mode)&256)}_remove(e,t,n){let r=S.join(e,t),i=S.resolve(r);if(n??=this._watched.has(r)||this._watched.has(i),!this._throttle(`remove`,r,100))return;!n&&this._watched.size===1&&this.add(e,t,!0),this._getWatchedDir(r).getChildren().forEach(e=>this._remove(r,e));let a=this._getWatchedDir(e),o=a.has(t);a.remove(t),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let s=r;if(this.options.cwd&&(s=S.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(s)&&this._pendingWrites.get(s).cancelWait()===z.ADD)return;this._watched.delete(r),this._watched.delete(i);let c=n?z.UNLINK_DIR:z.UNLINK;o&&!this._isIgnored(r)&&this._emit(c,r),this._closePath(r)}_closePath(e){this._closeFile(e);let t=S.dirname(e);this._getWatchedDir(t).remove(S.basename(e))}_closeFile(e){let t=this._closers.get(e);t&&(t.forEach(e=>e()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let n=this._closers.get(e);n||(n=[],this._closers.set(e,n)),n.push(t)}_readdirp(e,t){if(this.closed)return;let n=lt(e,{type:z.ALL,alwaysStat:!0,lstat:!0,...t,depth:0});return this._streams.add(n),n.once(`close`,()=>{n=void 0}),n.once(`end`,()=>{n&&=(this._streams.delete(n),void 0)}),n}};function Vt(e,t={}){let n=new Bt(t);return n.add(e),n}function Ht(e){if(!e.includes(`defineRootContext`))return``;let{descriptor:t}=g(e);if(!t.scriptSetup)return``;let n=e=t.scriptSetup.content,r=Ut(n);return n.substring(r.start,r.end+1).trim()}function Ut(e){return Me(e,`defineRootContext`)}function Wt(e){if(!e.includes(`<template`))return``;let{descriptor:t}=g(e);return(t.template?.content||``).trim()}function Gt(e,t){if(!e)throw Error(`[oiyo] App.vue 必须包含 <template> 节点`);let n=e.content;if(!(n.includes(`<OiyoPage`)||n.includes(`<oiyo-page`)))throw Error(`[oiyo] App.vue 的 template 必须包含 <OiyoPage /> 或 <oiyo-page /> 占位节点`);if(t.varName&&(n=n.replace(RegExp(`\\b${t.varName}\\b`,`g`),`$oiyoRootContext`)),t.varProperties?.length)for(let{local:e,original:r}of t.varProperties)n=n.replace(RegExp(`\\b${e}\\b`,`g`),`$oiyoRootContext.${r}`);return n.trim()}function Kt(e){if(!e)return;let t=e?.content;if(t){let e=qt(t);return e.script?e:void 0}}function qt(e){let t=p(e,{sourceType:`module`,plugins:[`typescript`]}),n={};return C(t,{ImportDeclaration(t){let r=e.substring(t.node.start,t.node.end);n.imports??=[],n.imports.push(r)},CallExpression(t){let{callee:r,arguments:i}=t.node;if(r.type===`Identifier`&&r.name===`defineRootContext`&&i.length>0){let r=i[0];r.start!=null&&r.end!=null&&(n.script=e.substring(r.start,r.end));let a=t.findParent(e=>e.isVariableDeclarator());if(a&&a.isVariableDeclarator()){let e=a.node.id;e.type===`Identifier`?n.variable=e.name:e.type===`ObjectPattern`&&(n.properties=e.properties.filter(e=>e.type===`ObjectProperty`).map(e=>({original:e.key.type===`Identifier`?e.key.name:String(e.key.value),local:e.value.type===`Identifier`?e.value.name:e.key.name})))}}}}),n}function Jt(e,t){let n=e;return n=n.replace(/<OiyoPage[^>]*?\/>/g,t),n=n.replace(/<OiyoPage[^>]*>\s*<\/OiyoPage>/g,t),n=n.replace(/<oiyo-page[^>]*?\/>/g,t),n=n.replace(/<oiyo-page[^>]*>\s*<\/oiyo-page>/g,t),n}const Yt=`virtual:oiyo-root-context`,$=`\0${Yt}`;function Xt(e){let{script:t,imports:n}=e,r=[];return n?.length&&(r.push(...n),r.push(``)),t?(r.push(`let rootContextInstance = null`),r.push(``),r.push(`export function useRootContext() {`),r.push(`if (!rootContextInstance) {`),r.push(`const factory = ${t}`),r.push(`rootContextInstance = factory()`),r.push(`}`),r.push(`return rootContextInstance`),r.push(`}`)):(r.push(`export function useRootContext() {`),r.push(`return {}`),r.push(`}`)),r.join(`
13
+ `)}var Zt=class{constructor(e,t){this.config=e,this.rootView={imports:[],template:`<OiyoPage />`,script:``},this.shouldRefreshVM=e=>{let t=``;this.rootMarco&&(t=w(Ne(`defineRootContext(${this.rootMarco.script})`)));let n=w(Ne(Ht(e)));return t!==n},this.logger=t.logger.withScope(`ROOT`)}get srcDir(){return s(this.config.rootDir,this.config.srcDir)}get rootPath(){return s(this.srcDir,`App.vue`)}isRootPath(e){return e===this.rootPath}parseRoot(e){let{descriptor:t}=g(e),n=Kt(t.scriptSetup);return this.rootView={template:Gt(t.template,{varName:n?.variable,varProperties:n?.properties}),imports:[],script:``},n&&(this.rootMarco=n,this.rootVM=Xt(n),n.script&&(this.rootView.imports.push(`import { useRootContext } from 'virtual:oiyo-root-context'`),this.rootView.script=`const $oiyoRootContext = useRootContext()`)),{view:this.rootView,marco:n}}transformRoot(e){let{descriptor:t}=g(e),n=new v(e);if(t.template){let e=t.template.loc.start.offset-10,r=t.template.loc.end.offset+11;n.remove(e,r)}if(t.scriptSetup){let e=t.scriptSetup.content,r=Ut(e);if(r.start!==r.end){e.includes(`virtual:oiyo-root-context`)||n.appendLeft(t.scriptSetup.loc.start.offset,`
14
+ import { useRootContext } from 'virtual:oiyo-root-context'
15
+ `);let i=t.scriptSetup.loc.start.offset+r.start,a=t.scriptSetup.loc.start.offset+r.end;i!==a&&n.overwrite(i,a,`useRootContext()`)}}return{code:n.toString(),sourceMap:n.generateMap()}}shouldRefreshView(e){return w(this.rootView.template)!==w(Wt(e))}applyRoot(e){let t=[],n=``,r=``;return e.template&&(n=Jt(this.rootView.template,e.template.content)),e.scriptSetup&&(t.push(...this.rootView.imports),r=`${this.rootView.script}\n${e.scriptSetup.content}`),{imports:t,script:r,template:n}}};function Qt(e){let t=!1,n=`build`;return e.logger.withScope(`VITE`),[{name:`oiyo:build`,apply:`build`,enforce:`pre`,configResolved(e){n=e.command},async buildStart(){if(t)return;await Promise.all([e.page.loadPagesConfig(),e.page.loadPagesJson(),e.layout.registerLayouts()]);let r=t=>{e.layout.isLayoutPath(t)&&e.layout.registerLayouts()};n===`serve`&&Vt(e.layout.layoutDir,{ignoreInitial:!0}).on(`add`,r).on(`unlink`,r),t=!0},async transform(t,n){if(e.root.isRootPath(n))return e.root.parseRoot(t),e.root.transformRoot(t);if(e.page.isPagePath(n))return this.addWatchFile(e.root.rootPath),e.page.transformPage(t,n)},resolveId(e){if(e===`virtual:oiyo-root-context`)return $},load(t){if(t===$)return e.root.rootVM||`export function useRootContext() {return {}}`},async closeBundle(){await e.page.unwatchPagesConfig()}}]}function $t(){return[{name:`oiyo:deps`,enforce:`pre`,config(e){return _(e,{optimizeDeps:{exclude:[`@skiyee/oiyo`]}})}}]}function en(e){let n=t(e),r=D();r.withScope(`CONFIG`);let i=new Zt(n,{logger:r}),a=new ze(n,{logger:r});return{logger:r,root:i,layout:a,page:new A(n,{oiyoRoot:i,oiyoLayout:a,logger:r})}}function tn(e){return e.logger.withScope(`VITE`),e.logger.withScope(`HMR`),[{name:`oiyo:serve`,apply:`serve`,enforce:`pre`,async buildStart(){await Promise.all([e.page.loadPagesConfig(),e.page.loadPagesJson(),e.layout.registerLayouts()])},configureServer(t){e.page.watchPagesConfig(()=>{t.hot.send({type:`full-reload`})});let n=t=>{e.layout.isLayoutPath(t)&&e.layout.registerLayouts()};t.watcher.on(`add`,n),t.watcher.on(`unlink`,n)},async transform(t,n){if(e.root.isRootPath(n))return e.root.parseRoot(t),e.root.transformRoot(t);if(e.page.isPagePath(n))return this.addWatchFile(e.root.rootPath),e.page.transformPage(t,n)},resolveId(e){if(e===`virtual:oiyo-root-context`)return $},load(t){if(t===$)return e.root.rootVM||`export function useRootContext() {return {}}`},async handleHotUpdate({file:t,server:n,read:r}){if(e.root.isRootPath(t)){let t=await r(),i=!1;if(e.root.shouldRefreshView(t)&&(i=!0),e.root.shouldRefreshVM(t)){let e=n.moduleGraph.getModuleById($);e&&(n.moduleGraph.invalidateModule(e),i=!0)}if(i){n.hot.send({type:`full-reload`});return}}},async closeBundle(){await e.page.unwatchPagesConfig()}}]}function nn(e={}){let t=en(e);return[...$t(),...tn(t),...Qt(t)]}export{T as LogLevels,nn as OiyoCorePlugin,ze as OiyoLayout,A as OiyoPage,Zt as OiyoRoot,$ as RESOLVED_VIRTUAL_ROOT_CONTEXT_ID,Yt as VIRTUAL_ROOT_CONTEXT_ID,D as createLogger};
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @oiyo/core v0.0.1
3
+ * Copyright (c) 2026 skiyee. All rights reserved.
4
+ * Commercial software. See LICENSE for terms.
5
+ * Official site: https://oiyo.pages.dev
6
+ */
7
+ import { GlobalStyle } from "@oiyo/config";
8
+
9
+ //#region src/page/types.d.ts
10
+ /**
11
+ * 可序列化的页面元信息值类型
12
+ * 用于静态提取和 pages.json 生成
13
+ */
14
+ type PageMetaValue = string | number | boolean | null | PageMetaObject | PageMetaValue[];
15
+ /**
16
+ * 可序列化的页面元信息对象
17
+ */
18
+ interface PageMetaObject {
19
+ [key: string]: PageMetaValue | undefined;
20
+ }
21
+ /**
22
+ * 页面元信息基础字段
23
+ */
24
+ interface BasePageMeta {
25
+ /** 页面类型 */
26
+ type?: 'page' | 'home';
27
+ /** 使用的布局名称,false 表示不使用布局 */
28
+ layout?: string | false;
29
+ /** 中间件 */
30
+ middleware?: string | string[];
31
+ /** uni-app 页面样式配置 */
32
+ style?: GlobalStyle;
33
+ }
34
+ /**
35
+ * 已解析的页面元信息
36
+ * 用于编译期静态提取和 pages.json 生成
37
+ */
38
+ interface ResolvedPageMeta extends BasePageMeta, PageMetaObject {}
39
+ /**
40
+ * 页面文件信息
41
+ */
42
+ interface PageFile {
43
+ /** 页面路径(相对于 srcDir,不含扩展名) */
44
+ pagePath: string;
45
+ /** 页面文件的绝对路径 */
46
+ filePath: string;
47
+ /** 页面元信息 */
48
+ pageMeta: ResolvedPageMeta;
49
+ /** 所属包(main 或子包名称) */
50
+ pageBelong: string;
51
+ }
52
+ //#endregion
53
+ export { PageFile as n, ResolvedPageMeta as r, BasePageMeta as t };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @oiyo/core v0.0.1
3
+ * Copyright (c) 2026 skiyee. All rights reserved.
4
+ * Commercial software. See LICENSE for terms.
5
+ * Official site: https://oiyo.pages.dev
6
+ */
7
+ import { GlobalStyle } from "@oiyo/config";
8
+
9
+ //#region src/page/types.d.ts
10
+ /**
11
+ * 可序列化的页面元信息值类型
12
+ * 用于静态提取和 pages.json 生成
13
+ */
14
+ type PageMetaValue = string | number | boolean | null | PageMetaObject | PageMetaValue[];
15
+ /**
16
+ * 可序列化的页面元信息对象
17
+ */
18
+ interface PageMetaObject {
19
+ [key: string]: PageMetaValue | undefined;
20
+ }
21
+ /**
22
+ * 页面元信息基础字段
23
+ */
24
+ interface BasePageMeta {
25
+ /** 页面类型 */
26
+ type?: 'page' | 'home';
27
+ /** 使用的布局名称,false 表示不使用布局 */
28
+ layout?: string | false;
29
+ /** 中间件 */
30
+ middleware?: string | string[];
31
+ /** uni-app 页面样式配置 */
32
+ style?: GlobalStyle;
33
+ }
34
+ /**
35
+ * 已解析的页面元信息
36
+ * 用于编译期静态提取和 pages.json 生成
37
+ */
38
+ interface ResolvedPageMeta extends BasePageMeta, PageMetaObject {}
39
+ /**
40
+ * 页面文件信息
41
+ */
42
+ interface PageFile {
43
+ /** 页面路径(相对于 srcDir,不含扩展名) */
44
+ pagePath: string;
45
+ /** 页面文件的绝对路径 */
46
+ filePath: string;
47
+ /** 页面元信息 */
48
+ pageMeta: ResolvedPageMeta;
49
+ /** 所属包(main 或子包名称) */
50
+ pageBelong: string;
51
+ }
52
+ //#endregion
53
+ export { PageFile as n, ResolvedPageMeta as r, BasePageMeta as t };
package/dist/types.cjs ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @oiyo/core v0.0.1
3
+ * Copyright (c) 2026 skiyee. All rights reserved.
4
+ * Commercial software. See LICENSE for terms.
5
+ * Official site: https://oiyo.pages.dev
6
+ */
7
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @oiyo/core v0.0.1
3
+ * Copyright (c) 2026 skiyee. All rights reserved.
4
+ * Commercial software. See LICENSE for terms.
5
+ * Official site: https://oiyo.pages.dev
6
+ */
7
+ import { t as BasePageMeta } from "./types-D6ttx3rg.cjs";
8
+
9
+ //#region src/types.d.ts
10
+ /**
11
+ * 页面元信息
12
+ * 用户在 definePageMeta() 中使用的类型
13
+ * 支持通过 declare module '@skiyee/oiyo' 进行扩展
14
+ */
15
+ interface PageMeta extends BasePageMeta {
16
+ /** 其他自定义字段 */
17
+ [key: string]: unknown;
18
+ }
19
+ /**
20
+ * 根上下文工厂函数
21
+ */
22
+ type RootContextFactory<T extends object> = () => T;
23
+ declare global {
24
+ /**
25
+ * 定义页面元信息
26
+ * @param meta 页面元信息配置
27
+ */
28
+ function definePageMeta(meta: PageMeta): void;
29
+ /**
30
+ * 定义根上下文
31
+ * @param factory 返回上下文对象的工厂函数
32
+ * @returns 上下文对象
33
+ */
34
+ function defineRootContext<T extends object>(factory: RootContextFactory<T>): T;
35
+ }
36
+ //#endregion
37
+ export { PageMeta, RootContextFactory };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @oiyo/core v0.0.1
3
+ * Copyright (c) 2026 skiyee. All rights reserved.
4
+ * Commercial software. See LICENSE for terms.
5
+ * Official site: https://oiyo.pages.dev
6
+ */
7
+ import { t as BasePageMeta } from "./types-CbY0rJue.mjs";
8
+
9
+ //#region src/types.d.ts
10
+ /**
11
+ * 页面元信息
12
+ * 用户在 definePageMeta() 中使用的类型
13
+ * 支持通过 declare module '@skiyee/oiyo' 进行扩展
14
+ */
15
+ interface PageMeta extends BasePageMeta {
16
+ /** 其他自定义字段 */
17
+ [key: string]: unknown;
18
+ }
19
+ /**
20
+ * 根上下文工厂函数
21
+ */
22
+ type RootContextFactory<T extends object> = () => T;
23
+ declare global {
24
+ /**
25
+ * 定义页面元信息
26
+ * @param meta 页面元信息配置
27
+ */
28
+ function definePageMeta(meta: PageMeta): void;
29
+ /**
30
+ * 定义根上下文
31
+ * @param factory 返回上下文对象的工厂函数
32
+ * @returns 上下文对象
33
+ */
34
+ function defineRootContext<T extends object>(factory: RootContextFactory<T>): T;
35
+ }
36
+ //#endregion
37
+ export { PageMeta, RootContextFactory };
package/dist/types.mjs ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @oiyo/core v0.0.1
3
+ * Copyright (c) 2026 skiyee. All rights reserved.
4
+ * Commercial software. See LICENSE for terms.
5
+ * Official site: https://oiyo.pages.dev
6
+ */
7
+ export{};
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@oiyo/core",
3
+ "type": "module",
4
+ "version": "0.0.1",
5
+ "author": {
6
+ "name": "skiyee",
7
+ "email": "319619193@qq.com",
8
+ "url": "https://skiyee.pages.dev"
9
+ },
10
+ "license": "SEE LICENSE IN LICENSE",
11
+ "funding": "https://github.com/skiyee/sponsors",
12
+ "homepage": "https://oiyo.pages.dev",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/skiyee/oiyo.git"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/skiyee/oiyo/issues"
19
+ },
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.mts",
23
+ "import": "./dist/index.mjs",
24
+ "require": "./dist/index.cjs"
25
+ },
26
+ "./types": "./dist/types.d.mts",
27
+ "./package.json": "./package.json"
28
+ },
29
+ "main": "./dist/index.cjs",
30
+ "module": "./dist/index.mjs",
31
+ "types": "./dist/index.d.mts",
32
+ "files": [
33
+ "THIRD_PARTY_NOTICES.md",
34
+ "dist"
35
+ ],
36
+ "peerDependencies": {
37
+ "vite": "5.2.8"
38
+ },
39
+ "dependencies": {
40
+ "@babel/parser": "^7.28.4",
41
+ "@babel/traverse": "^7.28.4",
42
+ "@vue/compiler-sfc": "3.4.21",
43
+ "ansis": "^4.2.0",
44
+ "c12": "^3.3.3",
45
+ "defu": "^6.1.4",
46
+ "magic-string": "^0.30.21",
47
+ "pathe": "^2.0.3",
48
+ "tinyglobby": "^0.2.15",
49
+ "@oiyo/config": "0.0.1"
50
+ },
51
+ "devDependencies": {
52
+ "chokidar": "4.0.3",
53
+ "vite": "5.2.8"
54
+ },
55
+ "scripts": {
56
+ "build": "tsdown",
57
+ "dev": "tsdown --watch",
58
+ "test": "vitest",
59
+ "test:run": "vitest run"
60
+ }
61
+ }