diff --git a/packages/page/src/asset.ts b/packages/page/src/asset.ts
index 6de0e39..defaad7 100644
--- a/packages/page/src/asset.ts
+++ b/packages/page/src/asset.ts
@@ -60,7 +60,7 @@ class AssetNode {
export type { Asset, AssetNode }
-export class AssetLeaf {
+export class AssetAbst {
constructor(private readonly load: (() => Awaitable) | string) {}
instantiate(parent: Base): PromiseLike {
diff --git a/packages/page/src/find.ts b/packages/page/src/find.ts
index 245face..25e2a82 100644
--- a/packages/page/src/find.ts
+++ b/packages/page/src/find.ts
@@ -126,15 +126,15 @@ class FileNameTransition extends Transition {
export type { Transition }
type NextPath = Readonly
-export type Next = Readonly<{ leaf: Leaf; relPath: NextPath }>
+export type Next = Readonly<{ abst: Abst; relPath: NextPath }>
-export class Indices {
- readonly moduleNameMap = new ModuleNameTransition>()
- readonly stemMap = new ModuleNameTransition>()
- readonly fileNameMap = new FileNameTransition>()
+export class Indices {
+ readonly moduleNameMap = new ModuleNameTransition>()
+ readonly stemMap = new ModuleNameTransition>()
+ readonly fileNameMap = new FileNameTransition>()
- addRoute(leaf: Leaf, relPath: NextPath): void {
- const next = { leaf, relPath }
+ addRoute(abst: Abst, relPath: NextPath): void {
+ const next = { abst, relPath }
const moduleSteps = PathSteps.fromRelativeModuleName(relPath.moduleName)
const stemSteps = PathSteps.fromRelativeModuleName(relPath.stem)
const fileSteps = PathSteps.fromRelativeFileName(relPath.fileName)
@@ -144,7 +144,7 @@ export class Indices {
}
}
-export interface TreeLeaf {
+export interface TreeAbst {
readonly instantiate: (parent: Tree, path: NextPath) => PromiseLike
}
@@ -156,7 +156,7 @@ interface TreeNode {
type Content =
| ((...a: never) => unknown)
- | PromiseLike<{ [P in Key]: Transition>> }>
+ | PromiseLike<{ [P in Key]: Transition>> }>
const undef = Promise.resolve(undefined)
@@ -206,7 +206,7 @@ export const find = <
trie.value?.reduceRight((cont, { next, epsilon }) => {
return r =>
r ??
- next.leaf.instantiate(node, next.relPath).then(inst => {
+ next.abst.instantiate(node, next.relPath).then(inst => {
return epsilon
? search(inst, key, final).then(cont)
: check(inst, key, final ?? true).then(cont)
diff --git a/packages/page/src/page.ts b/packages/page/src/page.ts
index 94b94b3..b925789 100644
--- a/packages/page/src/page.ts
+++ b/packages/page/src/page.ts
@@ -4,9 +4,9 @@ import { type Pairs, type List, iteratePairs, listItems } from './items'
import { constProp } from './util'
import { type Delay, delay } from './delay'
import { type RelPath, PathSteps, concatFileName } from './filename'
-import { type Asset, type AssetModule, AssetLeaf } from './asset'
+import { type Asset, type AssetModule, AssetAbst } from './asset'
import type { Loaded, MainModule, Dir, TreeNode, Inst } from './tree'
-import { Tree, TreeLeafImpl } from './tree'
+import { Tree, TreeAbstImpl } from './tree'
const dummyRelPath: Readonly = {
moduleName: '',
@@ -64,13 +64,13 @@ class PageFactory<
Args extends unknown[]
> {
readonly basis: This
- readonly leaf: TreeLeafImpl
+ readonly abst: TreeAbstImpl
constructor(
This: PageConstructor,
arg: NewArg,
args: Args,
- content: TreeLeafImpl['content']
+ content: TreeAbstImpl['content']
) {
this.basis = new This(...args)
if (arg.parsePath != null) {
@@ -87,35 +87,35 @@ class PageFactory<
}
const init = {
rootURL: arg.url != null ? new URL(arg.url) : undefined,
- fileName: TreeLeafImpl.currentFileName(),
+ fileName: TreeAbstImpl.currentFileName(),
basis: this.basis,
content,
Base: This.Base
}
- this.leaf = TreeLeafImpl.decorate(init)
+ this.abst = TreeAbstImpl.decorate(init)
}
createSubpage(
dir: Dir,
- content: TreeLeafImpl['content'],
+ content: TreeAbstImpl['content'],
relPath: Readonly
- ): TreeLeafImpl {
+ ): TreeAbstImpl {
const arg = {
- rootURL: this.leaf.rootURL,
- fileName: concatFileName(this.leaf.fileName, relPath?.fileName),
+ rootURL: this.abst.rootURL,
+ fileName: concatFileName(this.abst.fileName, relPath?.fileName),
basis: this.basis,
content,
- Base: this.leaf.Base
+ Base: this.abst.Base
}
- const leaf = TreeLeafImpl.decorate(arg)
- dir.addRoute(leaf, relPath)
- return leaf
+ const abst = TreeAbstImpl.decorate(arg)
+ dir.addRoute(abst, relPath)
+ return abst
}
async createModuleDirectory(
arg: Readonly>
): Promise> {
- const dir = TreeLeafImpl.createDirectory()
+ const dir = TreeAbstImpl.createDirectory()
const substPath = (path: string): Awaitable =>
arg.substitutePath != null
? Reflect.apply(arg.substitutePath, this.basis, [path])
@@ -135,9 +135,9 @@ class PageFactory<
fileName: PathSteps.normalize(path)
}
}
- const leaf = this.leaf.getTreeLeaf(load)
- if (leaf != null) {
- dir.addRoute(leaf, relPath)
+ const abst = this.abst.getTreeAbst(load)
+ if (abst != null) {
+ dir.addRoute(abst, relPath)
} else if (typeof load === 'function') {
this.createSubpage(dir, load, relPath)
} else {
@@ -148,8 +148,8 @@ class PageFactory<
if (arg.assets != null) {
for await (const [path, load] of iteratePairs(arg.assets, this.basis)) {
const loader = load ?? (await substPath(path))
- const leaf = new AssetLeaf>(loader)
- const pair = { leaf, relPath: dummyRelPath }
+ const abst = new AssetAbst>(loader)
+ const pair = { abst, relPath: dummyRelPath }
dir.fileNameMap.addRoute(PathSteps.fromRelativeFileName(path), pair)
}
}
@@ -159,18 +159,18 @@ class PageFactory<
async createPaginateDirectory- (
arg: Readonly>
): Promise> {
- const dir = TreeLeafImpl.createDirectory()
+ const dir = TreeAbstImpl.createDirectory()
const rawPageSize = arg.pageSize ?? 10
const pageSize = rawPageSize >= 1 ? rawPageSize : 1
const load = arg.load
- const allItems = await listItems(arg.items, this.leaf.basis)
+ const allItems = await listItems(arg.items, this.abst.basis)
const numAllItems = allItems.length
const numPages = Math.ceil(numAllItems / pageSize)
const pages: Array> = []
for (let pageIndex = 0; pageIndex < numPages; pageIndex++) {
const itemIndex = pageIndex * pageSize
const items = allItems.slice(itemIndex, itemIndex + pageSize)
- const relPath = this.leaf.basis.paginatePath(pageIndex)
+ const relPath = this.abst.basis.paginatePath(pageIndex)
const page = undefined as unknown as This // dummy
const pagi = { pages, page, pageIndex, items, itemIndex, numAllItems }
const content = (): Loaded => Reflect.apply(load, pagi.page, [pagi])
@@ -203,7 +203,7 @@ export class Page<
type F = PageFactory & This, Impl, Args>
const dir = delay(async () => await factory.createModuleDirectory(arg))
const factory: F = new PageFactory(this, arg, args, dir)
- return factory.leaf.basis
+ return factory.abst.basis
}
static paginate<
@@ -220,7 +220,7 @@ export class Page<
type F = PageFactory & This, Impl, Args>
const dir = delay(async () => await factory.createPaginateDirectory(arg))
const factory: F = new PageFactory(this, arg, args, dir)
- return factory.leaf.basis
+ return factory.abst.basis
}
parsePath(fileName: string): ParsePath {
diff --git a/packages/page/src/ref.ts b/packages/page/src/ref.ts
index 3ac9e9b..3e9b134 100644
--- a/packages/page/src/ref.ts
+++ b/packages/page/src/ref.ts
@@ -1,7 +1,7 @@
import type { ModuleName } from '../../vite-plugin-minissg/src/module'
import { type Awaitable, raise } from '../../vite-plugin-minissg/src/util'
import { type Delay, delay } from './delay'
-import type { Transition, Next, TreeLeaf } from './find'
+import type { Transition, Next, TreeAbst } from './find'
import type { RelPath } from './filename'
interface SomeNode {
@@ -10,7 +10,7 @@ interface SomeNode {
interface TreeNode extends SomeNode {
readonly content:
| ((...a: never) => unknown)
- | PromiseLike<{ moduleNameMap: Transition>> }>
+ | PromiseLike<{ moduleNameMap: Transition>> }>
readonly findChild: () => PromiseLike
readonly parent: Tree | undefined
readonly root: Tree
@@ -118,7 +118,7 @@ const descendants = , Inst extends SomeNode>(
const k = (i: number): Awaitable => {
const next = branches[i]
if (next == null) return skip.then(last).then(cont)
- return next.leaf
+ return next.abst
.instantiate(tree, next.relPath)
.then(node => descendants(node, wait, except, queue, () => k(i + 1)))
}
diff --git a/packages/page/src/tree.ts b/packages/page/src/tree.ts
index f84e953..ddb3824 100644
--- a/packages/page/src/tree.ts
+++ b/packages/page/src/tree.ts
@@ -8,7 +8,7 @@ import { Memo } from './memo'
import { PathSteps, FileName, concatName, concatFileName } from './filename'
import type { RelPath } from './filename'
import { type Next, Indices, find } from './find'
-import type { Asset, AssetNode, AssetLeaf } from './asset'
+import type { Asset, AssetNode, AssetAbst } from './asset'
import { Ref } from './ref'
export type MainModule = Readonly<{ main: minissg.Main }>
@@ -21,10 +21,10 @@ export const isMinissgMainModule = (x: unknown): x is MainModule =>
type TreeImpl =
| TreeNodeImpl
- | TreeLeafImpl
+ | TreeAbstImpl
const currentNode = new AsyncLocalStorage>()
-const internal = new WeakMap