@deot/docs-playground 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/cdn-BoYKnGD3.cjs +101 -0
- package/dist/cdn-DQoETju_.js +54 -0
- package/dist/compile-BHD98Ttf.js +325 -0
- package/dist/compile-Da095AyM.cjs +325 -0
- package/dist/files-BqucFldk.js +207 -0
- package/dist/files-BsAOZiPN.cjs +267 -0
- package/dist/index.cjs +221 -1050
- package/dist/index.d.ts +4 -2
- package/dist/index.js +178 -986
- package/dist/index.style.css +1 -1
- package/dist/linker-DIpEiean.cjs +167 -0
- package/dist/linker-xqjVl0X0.js +166 -0
- package/dist/local-sandbox-0ojvBQPO.cjs +432 -0
- package/dist/local-sandbox-DvcgaBOa.js +424 -0
- package/dist/modules-BGzPcoRR.js +217 -0
- package/dist/modules-E6kK6ZJH.cjs +223 -0
- package/dist/remote-BG0E1Ugo.cjs +152 -0
- package/dist/remote-mq4zvrI1.js +152 -0
- package/dist/rolldown-runtime-C0BPl7ul.cjs +43 -0
- package/dist/script-BiCcpu3G.cjs +111 -0
- package/dist/script-DjUf9uWK.js +98 -0
- package/dist/scss-B8OFbz1k.cjs +251 -0
- package/dist/scss-DIh6971q.js +227 -0
- package/dist/store-BOyC8F2y.js +910 -0
- package/dist/store-DKawhFZu.cjs +1109 -0
- package/package.json +21 -9
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
|
|
2
|
+
//#region packages/playground/src/core/runtime/local/compile/types.ts
|
|
3
|
+
var IGNORED_FILENAMES = /* @__PURE__ */ new Set(["import-map.json", "tsconfig.json"]);
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region packages/playground/src/core/runtime/local/compile/files.ts
|
|
6
|
+
var files_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
7
|
+
basename: () => basename,
|
|
8
|
+
collectBareSpecifiers: () => collectBareSpecifiers,
|
|
9
|
+
collectReachableFilenames: () => collectReachableFilenames,
|
|
10
|
+
createFileIndex: () => createFileIndex,
|
|
11
|
+
dirname: () => dirname,
|
|
12
|
+
getCommonRoot: () => getCommonRoot,
|
|
13
|
+
getExtension: () => getExtension,
|
|
14
|
+
isIgnoredFilename: () => isIgnoredFilename,
|
|
15
|
+
isInsideRoot: () => isInsideRoot,
|
|
16
|
+
isRelativeSpecifier: () => isRelativeSpecifier,
|
|
17
|
+
joinVirtualPath: () => joinVirtualPath,
|
|
18
|
+
listImportSpecifiers: () => listImportSpecifiers,
|
|
19
|
+
normalizeVirtualPath: () => normalizeVirtualPath,
|
|
20
|
+
resolveEntry: () => resolveEntry,
|
|
21
|
+
resolveModulePath: () => resolveModulePath
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* 统一成以 `/` 开头的 POSIX 绝对虚拟路径。
|
|
25
|
+
* `App.vue` 与 `/App.vue` 是同一文件,和 iframe 预览使用的 files 键一致。
|
|
26
|
+
* @param filename Playground files 的键或相对路径。
|
|
27
|
+
* @returns 以 `/` 开头的虚拟路径。
|
|
28
|
+
*/
|
|
29
|
+
var normalizeVirtualPath = (filename) => {
|
|
30
|
+
const raw = String(filename || "").replace(/\\/gu, "/").trim();
|
|
31
|
+
if (!raw) return "/";
|
|
32
|
+
const parts = (raw.startsWith("/") ? raw : `/${raw}`).split("/");
|
|
33
|
+
const stack = [];
|
|
34
|
+
for (const part of parts) {
|
|
35
|
+
if (!part || part === ".") continue;
|
|
36
|
+
if (part === "..") {
|
|
37
|
+
if (stack.length) stack.pop();
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
stack.push(part);
|
|
41
|
+
}
|
|
42
|
+
return `/${stack.join("/")}`;
|
|
43
|
+
};
|
|
44
|
+
var dirname = (filename) => {
|
|
45
|
+
const path = normalizeVirtualPath(filename);
|
|
46
|
+
const index = path.lastIndexOf("/");
|
|
47
|
+
if (index <= 0) return "/";
|
|
48
|
+
return path.slice(0, index) || "/";
|
|
49
|
+
};
|
|
50
|
+
var basename = (filename) => {
|
|
51
|
+
const path = normalizeVirtualPath(filename);
|
|
52
|
+
const index = path.lastIndexOf("/");
|
|
53
|
+
return index === -1 ? path : path.slice(index + 1);
|
|
54
|
+
};
|
|
55
|
+
var joinVirtualPath = (baseDir, relative) => {
|
|
56
|
+
const rel = String(relative || "").replace(/\\/gu, "/");
|
|
57
|
+
if (rel.startsWith("/")) return normalizeVirtualPath(rel);
|
|
58
|
+
const base = normalizeVirtualPath(baseDir);
|
|
59
|
+
return normalizeVirtualPath(`${base === "/" ? "" : base}/${rel}`);
|
|
60
|
+
};
|
|
61
|
+
var getExtension = (filename) => {
|
|
62
|
+
const name = basename(filename);
|
|
63
|
+
const index = name.lastIndexOf(".");
|
|
64
|
+
if (index <= 0) return "";
|
|
65
|
+
return name.slice(index).toLowerCase();
|
|
66
|
+
};
|
|
67
|
+
var isIgnoredFilename = (filename) => IGNORED_FILENAMES.has(basename(filename));
|
|
68
|
+
var createFileIndex = (files) => {
|
|
69
|
+
const index = /* @__PURE__ */ new Map();
|
|
70
|
+
Object.entries(files || {}).forEach(([filename, code]) => {
|
|
71
|
+
const normalized = normalizeVirtualPath(filename);
|
|
72
|
+
if (isIgnoredFilename(normalized)) return;
|
|
73
|
+
index.set(normalized, code);
|
|
74
|
+
});
|
|
75
|
+
return index;
|
|
76
|
+
};
|
|
77
|
+
var resolveEntry = (files, entry) => {
|
|
78
|
+
const index = createFileIndex(files);
|
|
79
|
+
if (!index.size) throw new Error("[Playground] files 为空,无法确定入口");
|
|
80
|
+
if (entry) {
|
|
81
|
+
const normalized = normalizeVirtualPath(entry);
|
|
82
|
+
if (isIgnoredFilename(normalized)) throw new Error(`[Playground] entry 不能是 ${basename(normalized)}`);
|
|
83
|
+
if (!index.has(normalized)) throw new Error(`[Playground] entry 不在 files 中: ${entry}`);
|
|
84
|
+
return normalized;
|
|
85
|
+
}
|
|
86
|
+
for (const key of Object.keys(files || {})) {
|
|
87
|
+
const normalized = normalizeVirtualPath(key);
|
|
88
|
+
if (!isIgnoredFilename(normalized) && index.has(normalized)) return normalized;
|
|
89
|
+
}
|
|
90
|
+
/* istanbul ignore next -- 忽略文件已在前面排除,正常 files 不会走到这里 */
|
|
91
|
+
throw new Error("[Playground] files 中没有可用的入口文件");
|
|
92
|
+
};
|
|
93
|
+
var CANDIDATE_EXTENSIONS = [
|
|
94
|
+
".vue",
|
|
95
|
+
".ts",
|
|
96
|
+
".js",
|
|
97
|
+
".tsx",
|
|
98
|
+
".jsx",
|
|
99
|
+
".json",
|
|
100
|
+
".css",
|
|
101
|
+
".scss",
|
|
102
|
+
".sass"
|
|
103
|
+
];
|
|
104
|
+
/**
|
|
105
|
+
* 相对 / 无扩展名解析,行为对齐 Vite:精确路径、补扩展名、`/index.*`。
|
|
106
|
+
* @param fromFilename 发起导入的文件。
|
|
107
|
+
* @param specifier 相对或绝对虚拟路径。
|
|
108
|
+
* @param fileIndex 虚拟路径到 files 键的索引。
|
|
109
|
+
* @returns 解析后的 files 键;找不到时返回 null。
|
|
110
|
+
*/
|
|
111
|
+
var resolveModulePath = (fromFilename, specifier, fileIndex) => {
|
|
112
|
+
if (!specifier || !(specifier === "." || specifier === ".." || specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/"))) return null;
|
|
113
|
+
const target = joinVirtualPath(dirname(fromFilename), specifier);
|
|
114
|
+
if (fileIndex.has(target)) return target;
|
|
115
|
+
for (const ext of CANDIDATE_EXTENSIONS) {
|
|
116
|
+
const withExt = `${target}${ext}`;
|
|
117
|
+
if (fileIndex.has(withExt)) return withExt;
|
|
118
|
+
}
|
|
119
|
+
for (const ext of CANDIDATE_EXTENSIONS) {
|
|
120
|
+
const asIndex = `${target}/index${ext}`;
|
|
121
|
+
if (fileIndex.has(asIndex)) return asIndex;
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
};
|
|
125
|
+
var getCommonRoot = (filenames) => {
|
|
126
|
+
const normalized = filenames.map(normalizeVirtualPath);
|
|
127
|
+
if (!normalized.length) return "/";
|
|
128
|
+
const split = normalized.map((path) => path.split("/").filter(Boolean));
|
|
129
|
+
const first = split[0];
|
|
130
|
+
let depth = first.length;
|
|
131
|
+
for (let i = 1; i < split.length; i += 1) {
|
|
132
|
+
let common = 0;
|
|
133
|
+
while (common < depth && common < split[i].length && first[common] === split[i][common]) common += 1;
|
|
134
|
+
depth = common;
|
|
135
|
+
}
|
|
136
|
+
if (!depth) return "/";
|
|
137
|
+
const maybeFile = `/${first.slice(0, depth).join("/")}`;
|
|
138
|
+
if (normalized.some((path) => path === maybeFile)) return dirname(maybeFile);
|
|
139
|
+
return maybeFile;
|
|
140
|
+
};
|
|
141
|
+
var isInsideRoot = (filename, root) => {
|
|
142
|
+
const path = normalizeVirtualPath(filename);
|
|
143
|
+
const base = normalizeVirtualPath(root);
|
|
144
|
+
if (base === "/") return true;
|
|
145
|
+
return path === base || path.startsWith(`${base}/`);
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* 静态 import / export-from / import() 的模块说明符。
|
|
149
|
+
* @param code 源码文本。
|
|
150
|
+
* @returns 按出现顺序收集到的说明符。
|
|
151
|
+
*/
|
|
152
|
+
var listImportSpecifiers = (code) => {
|
|
153
|
+
const result = [];
|
|
154
|
+
const source = String(code || "");
|
|
155
|
+
for (const match of source.matchAll(/(?:\bfrom\s+|import\s*\(\s*|import\s+)['"]([^'"]+)['"]/gu)) if (match[1]) result.push(match[1]);
|
|
156
|
+
return result;
|
|
157
|
+
};
|
|
158
|
+
var isRelativeSpecifier = (id) => id === "." || id === ".." || id.startsWith("./") || id.startsWith("../") || id.startsWith("/");
|
|
159
|
+
/**
|
|
160
|
+
* 从入口出发只编译静态 import 能走到的文件。
|
|
161
|
+
* @param files 当前 Playground 文件表。
|
|
162
|
+
* @param entry 入口文件名。
|
|
163
|
+
* @returns 可达文件名,入口在最前。
|
|
164
|
+
*/
|
|
165
|
+
var collectReachableFilenames = (files, entry) => {
|
|
166
|
+
const index = createFileIndex(files);
|
|
167
|
+
const ordered = [];
|
|
168
|
+
const seen = /* @__PURE__ */ new Set();
|
|
169
|
+
const visit = (filename) => {
|
|
170
|
+
const key = normalizeVirtualPath(filename);
|
|
171
|
+
if (seen.has(key) || !index.has(key)) return;
|
|
172
|
+
seen.add(key);
|
|
173
|
+
ordered.push(key);
|
|
174
|
+
listImportSpecifiers(index.get(key) || "").forEach((specifier) => {
|
|
175
|
+
const resolved = resolveModulePath(key, specifier, index);
|
|
176
|
+
if (resolved) visit(resolved);
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
visit(entry);
|
|
180
|
+
return ordered;
|
|
181
|
+
};
|
|
182
|
+
var collectBareSpecifiers = (files, filenames) => {
|
|
183
|
+
const index = createFileIndex(files);
|
|
184
|
+
const result = [];
|
|
185
|
+
const seen = /* @__PURE__ */ new Set();
|
|
186
|
+
filenames.forEach((filename) => {
|
|
187
|
+
listImportSpecifiers(index.get(normalizeVirtualPath(filename)) || "").forEach((specifier) => {
|
|
188
|
+
if (!specifier || isRelativeSpecifier(specifier) || seen.has(specifier) || /\.(?:css|scss|sass)(?:[?#]|$)/.test(specifier)) return;
|
|
189
|
+
seen.add(specifier);
|
|
190
|
+
result.push(specifier);
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
return result;
|
|
194
|
+
};
|
|
195
|
+
//#endregion
|
|
196
|
+
Object.defineProperty(exports, "collectBareSpecifiers", {
|
|
197
|
+
enumerable: true,
|
|
198
|
+
get: function() {
|
|
199
|
+
return collectBareSpecifiers;
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
Object.defineProperty(exports, "collectReachableFilenames", {
|
|
203
|
+
enumerable: true,
|
|
204
|
+
get: function() {
|
|
205
|
+
return collectReachableFilenames;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
Object.defineProperty(exports, "createFileIndex", {
|
|
209
|
+
enumerable: true,
|
|
210
|
+
get: function() {
|
|
211
|
+
return createFileIndex;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
Object.defineProperty(exports, "files_exports", {
|
|
215
|
+
enumerable: true,
|
|
216
|
+
get: function() {
|
|
217
|
+
return files_exports;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
Object.defineProperty(exports, "getCommonRoot", {
|
|
221
|
+
enumerable: true,
|
|
222
|
+
get: function() {
|
|
223
|
+
return getCommonRoot;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
Object.defineProperty(exports, "getExtension", {
|
|
227
|
+
enumerable: true,
|
|
228
|
+
get: function() {
|
|
229
|
+
return getExtension;
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
Object.defineProperty(exports, "isIgnoredFilename", {
|
|
233
|
+
enumerable: true,
|
|
234
|
+
get: function() {
|
|
235
|
+
return isIgnoredFilename;
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
Object.defineProperty(exports, "isInsideRoot", {
|
|
239
|
+
enumerable: true,
|
|
240
|
+
get: function() {
|
|
241
|
+
return isInsideRoot;
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
Object.defineProperty(exports, "isRelativeSpecifier", {
|
|
245
|
+
enumerable: true,
|
|
246
|
+
get: function() {
|
|
247
|
+
return isRelativeSpecifier;
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
Object.defineProperty(exports, "normalizeVirtualPath", {
|
|
251
|
+
enumerable: true,
|
|
252
|
+
get: function() {
|
|
253
|
+
return normalizeVirtualPath;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
Object.defineProperty(exports, "resolveEntry", {
|
|
257
|
+
enumerable: true,
|
|
258
|
+
get: function() {
|
|
259
|
+
return resolveEntry;
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
Object.defineProperty(exports, "resolveModulePath", {
|
|
263
|
+
enumerable: true,
|
|
264
|
+
get: function() {
|
|
265
|
+
return resolveModulePath;
|
|
266
|
+
}
|
|
267
|
+
});
|