tsprose 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 +21 -0
- package/README.md +152 -0
- package/dist/children.d.ts +3 -0
- package/dist/children.js +86 -0
- package/dist/default/mix.d.ts +10 -0
- package/dist/default/mix.js +6 -0
- package/dist/default/text.d.ts +10 -0
- package/dist/default/text.js +6 -0
- package/dist/document.d.ts +28 -0
- package/dist/document.js +61 -0
- package/dist/element.d.ts +33 -0
- package/dist/element.js +8 -0
- package/dist/elementUtils.d.ts +33 -0
- package/dist/elementUtils.js +92 -0
- package/dist/error.d.ts +3 -0
- package/dist/error.js +6 -0
- package/dist/externals.d.ts +57 -0
- package/dist/id.d.ts +3 -0
- package/dist/id.js +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +17 -0
- package/dist/json.d.ts +2 -0
- package/dist/json.js +46 -0
- package/dist/jsx-dev-runtime.d.ts +1 -0
- package/dist/jsx-dev-runtime.js +1 -0
- package/dist/jsx-runtime.d.ts +25 -0
- package/dist/jsx-runtime.js +24 -0
- package/dist/rawToProse.d.ts +19 -0
- package/dist/rawToProse.js +59 -0
- package/dist/schema.d.ts +25 -0
- package/dist/schema.js +7 -0
- package/dist/storage.d.ts +18 -0
- package/dist/storage.js +30 -0
- package/dist/tag.d.ts +45 -0
- package/dist/tag.js +53 -0
- package/dist/tagUtils.d.ts +12 -0
- package/dist/tagUtils.js +62 -0
- package/dist/unique.d.ts +25 -0
- package/dist/unique.js +81 -0
- package/dist/utils/hash.d.ts +1 -0
- package/dist/utils/hash.js +13 -0
- package/dist/walk.d.ts +13 -0
- package/dist/walk.js +72 -0
- package/package.json +49 -0
package/dist/walk.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export const WalkStop = { __TSPROSE_walkStop: true };
|
|
2
|
+
export const WalkNoDeeper = { __TSPROSE_walkNoDeeper: true };
|
|
3
|
+
export function isWalkStop(value) {
|
|
4
|
+
return value === WalkStop;
|
|
5
|
+
}
|
|
6
|
+
export function isWalkNoDeeper(value) {
|
|
7
|
+
return value === WalkNoDeeper;
|
|
8
|
+
}
|
|
9
|
+
export function walkPreSync(element, walkStep) {
|
|
10
|
+
const walkStepResult = walkStep(element);
|
|
11
|
+
if (isWalkStop(walkStepResult)) {
|
|
12
|
+
return WalkStop;
|
|
13
|
+
}
|
|
14
|
+
if (isWalkNoDeeper(walkStepResult)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const children = element.children;
|
|
18
|
+
if (children) {
|
|
19
|
+
for (const child of children) {
|
|
20
|
+
const childWalkResult = walkPreSync(child, walkStep);
|
|
21
|
+
if (isWalkStop(childWalkResult)) {
|
|
22
|
+
return WalkStop;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export async function walkPre(element, walkStep) {
|
|
28
|
+
const walkStepResult = await walkStep(element);
|
|
29
|
+
if (isWalkStop(walkStepResult)) {
|
|
30
|
+
return WalkStop;
|
|
31
|
+
}
|
|
32
|
+
if (isWalkNoDeeper(walkStepResult)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const children = element.children;
|
|
36
|
+
if (children) {
|
|
37
|
+
for (const child of children) {
|
|
38
|
+
const childWalkResult = await walkPre(child, walkStep);
|
|
39
|
+
if (isWalkStop(childWalkResult)) {
|
|
40
|
+
return WalkStop;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export function walkPostSync(element, walkStep) {
|
|
46
|
+
const childrenResults = [];
|
|
47
|
+
const children = element.children;
|
|
48
|
+
if (children) {
|
|
49
|
+
for (const child of children) {
|
|
50
|
+
const childResult = walkPostSync(child, walkStep);
|
|
51
|
+
if (isWalkStop(childResult)) {
|
|
52
|
+
return WalkStop;
|
|
53
|
+
}
|
|
54
|
+
childrenResults.push(childResult);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return walkStep(element, childrenResults);
|
|
58
|
+
}
|
|
59
|
+
export async function walkPost(element, walkStep) {
|
|
60
|
+
const childrenResults = [];
|
|
61
|
+
const children = element.children;
|
|
62
|
+
if (children) {
|
|
63
|
+
for (const child of children) {
|
|
64
|
+
const childResult = await walkPost(child, walkStep);
|
|
65
|
+
if (isWalkStop(childResult)) {
|
|
66
|
+
return WalkStop;
|
|
67
|
+
}
|
|
68
|
+
childrenResults.push(childResult);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return walkStep(element, childrenResults);
|
|
72
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tsprose",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "📜 Write and parse any prose in TypeScript TSX!",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"prose",
|
|
9
|
+
"typescript",
|
|
10
|
+
"tsx",
|
|
11
|
+
"text-processor",
|
|
12
|
+
"parser"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/Gwynerva/tsprose.git"
|
|
17
|
+
},
|
|
18
|
+
"main": "dist/index.js",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./jsx-runtime": {
|
|
26
|
+
"import": "./dist/jsx-runtime.js",
|
|
27
|
+
"types": "./dist/jsx-runtime.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./jsx-dev-runtime": {
|
|
30
|
+
"import": "./dist/jsx-dev-runtime.js",
|
|
31
|
+
"types": "./dist/jsx-dev-runtime.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./externals": "./dist/externals.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "rm -rf dist && bun tsc --project ./tsconfig.src.json && bun postBuild.ts",
|
|
40
|
+
"prepack": "bun run build",
|
|
41
|
+
"test": "bun vitest run",
|
|
42
|
+
"format": "prettier --write ."
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"prettier": "^3.8.1",
|
|
46
|
+
"typescript": "^5.9.3",
|
|
47
|
+
"vitest": "^4.0.18"
|
|
48
|
+
}
|
|
49
|
+
}
|