@weborigami/origami 0.0.73 → 0.1.0

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.
Files changed (194) hide show
  1. package/main.js +12 -0
  2. package/package.json +5 -7
  3. package/src/builtins.js +62 -0
  4. package/src/builtinsTree.js +36 -0
  5. package/src/calc/calc.js +61 -0
  6. package/src/cli/cli.js +6 -4
  7. package/src/{misc → common}/assertTreeIsDefined.js +4 -1
  8. package/src/common/constructHref.js +20 -0
  9. package/src/common/constructSiteTree.js +34 -0
  10. package/src/common/fetchAndHandleExtension.js +26 -0
  11. package/src/{misc → common}/getTreeArgument.js +11 -5
  12. package/src/common/processUnpackedContent.js +4 -13
  13. package/src/common/utilities.d.ts +0 -1
  14. package/src/common/utilities.js +3 -30
  15. package/src/deprecated.js +140 -0
  16. package/src/{common → dev}/ExplorableSiteTransform.js +1 -1
  17. package/src/{misc → dev}/OriCommandTransform.js +2 -2
  18. package/src/{builtins/@code.js → dev/code.js} +2 -2
  19. package/src/{builtins/@debug.js → dev/debug.js} +4 -7
  20. package/src/dev/dev.js +9 -0
  21. package/src/{builtins/@explore.js → dev/explore.js} +22 -28
  22. package/src/{misc → dev}/explore.js.inline +4 -4
  23. package/src/{misc → dev}/explore.ori +3 -3
  24. package/src/{builtins/@log.js → dev/log.js} +1 -1
  25. package/src/{builtins/@serve.js → dev/serve.js} +5 -8
  26. package/src/{builtins/@svg.js → dev/svg.js} +9 -6
  27. package/src/{misc → dev}/treeDot.js +0 -3
  28. package/src/{builtins/@watch.js → dev/watch.js} +8 -6
  29. package/src/handlers/handlerExports.js +16 -0
  30. package/src/handlers/handlers.js +37 -0
  31. package/src/{builtins → handlers}/js.handler.js +1 -1
  32. package/src/{builtins → handlers}/json.handler.js +9 -1
  33. package/src/handlers/mjs.handler.js +2 -0
  34. package/src/{builtins → handlers}/ori.handler.js +5 -7
  35. package/src/{builtins → handlers}/oridocument.handler.js +1 -1
  36. package/src/{builtins → handlers}/wasm.handler.js +1 -1
  37. package/src/{builtins → handlers}/yaml.handler.js +8 -1
  38. package/src/handlers/yml.handler.js +2 -0
  39. package/src/help/help.js +103 -0
  40. package/src/help/help.yaml +425 -0
  41. package/src/{builtins/@image → image}/format.js +2 -2
  42. package/src/{builtins/@image → image}/formatFn.js +1 -1
  43. package/src/image/image.js +2 -0
  44. package/src/{builtins/@image → image}/resize.js +2 -2
  45. package/src/{builtins/@image → image}/resizeFn.js +1 -1
  46. package/src/internal.js +24 -0
  47. package/src/{builtins/@js.js → js.js} +7 -6
  48. package/src/{builtins/@node.js → node.js} +1 -6
  49. package/src/{builtins/@basename.js → origami/basename.js} +2 -2
  50. package/src/{builtins/@config.js → origami/config.js} +1 -4
  51. package/src/{builtins/@json.js → origami/json.js} +2 -5
  52. package/src/{builtins/@jsonParse.js → origami/jsonParse.js} +0 -3
  53. package/src/{builtins/@once.js → origami/once.js} +2 -2
  54. package/src/{builtins/@ori.js → origami/ori.js} +4 -7
  55. package/src/origami/origami.js +29 -0
  56. package/src/{builtins/@pack.js → origami/pack.js} +2 -2
  57. package/src/{builtins/@project.js → origami/project.js} +7 -11
  58. package/src/{builtins/@regexMatch.js → origami/regexMatch.js} +1 -1
  59. package/src/origami/repeat.js +5 -0
  60. package/src/{builtins/@shell.js → origami/shell.js} +0 -3
  61. package/src/{builtins/@stdin.js → origami/stdin.js} +0 -3
  62. package/src/{builtins/@string.js → origami/string.js} +2 -2
  63. package/src/{builtins/@unpack.js → origami/unpack.js} +2 -2
  64. package/src/{builtins/@yaml.js → origami/yaml.js} +2 -5
  65. package/src/{builtins/@yamlParse.js → origami/yamlParse.js} +0 -3
  66. package/src/protocols/explore.js +19 -0
  67. package/src/{builtins/@files.js → protocols/files.js} +2 -5
  68. package/src/protocols/http.js +18 -0
  69. package/src/protocols/https.js +18 -0
  70. package/src/protocols/httpstree.js +19 -0
  71. package/src/protocols/httptree.js +19 -0
  72. package/src/protocols/inherited.js +18 -0
  73. package/src/protocols/new.js +42 -0
  74. package/src/{builtins/@package.js → protocols/package.js} +2 -2
  75. package/src/protocols/scope.js +14 -0
  76. package/src/server/constructResponse.js +5 -5
  77. package/src/{builtins/@siteAudit.js → site/audit.js} +4 -4
  78. package/src/{builtins/@crawl.js → site/crawler/crawl.js} +3 -6
  79. package/src/{crawler → site/crawler}/findPaths.js +2 -3
  80. package/src/{crawler → site/crawler}/utilities.js +2 -3
  81. package/src/{builtins/@index.js → site/index.js} +2 -5
  82. package/src/{builtins/@jsonKeys.js → site/jsonKeys.js} +5 -5
  83. package/src/{builtins/@rss.js → site/rss.js} +2 -5
  84. package/src/site/site.js +9 -0
  85. package/src/{builtins/@sitemap.js → site/sitemap.js} +8 -12
  86. package/src/{builtins/@static.js → site/static.js} +7 -7
  87. package/src/{builtins/@document.js → text/document.js} +2 -2
  88. package/src/{builtins/@inline.js → text/inline.js} +10 -13
  89. package/src/{builtins/@mdHtml.js → text/mdHtml.js} +7 -10
  90. package/src/text/origamiHighlightDefinition.js +53 -0
  91. package/src/text/text.js +4 -0
  92. package/src/{builtins/@addNextPrevious.js → tree/addNextPrevious.js} +7 -2
  93. package/src/{builtins/@cache.js → tree/cache.js} +2 -5
  94. package/src/{builtins/@clean.js → tree/clear.js} +4 -4
  95. package/src/{builtins/@concat.js → tree/concat.js} +2 -5
  96. package/src/{builtins/@copy.js → tree/copy.js} +3 -10
  97. package/src/{builtins/@deepMapFn.js → tree/deepMap.js} +13 -6
  98. package/src/{builtins/@deepMerge.js → tree/deepMerge.js} +4 -7
  99. package/src/{builtins/@deepReverse.js → tree/deepReverse.js} +8 -2
  100. package/src/tree/deepTake.js +26 -0
  101. package/src/{builtins/@deepValues.js → tree/deepValues.js} +2 -6
  102. package/src/{builtins/@defineds.js → tree/defineds.js} +7 -2
  103. package/src/{builtins/@filter.js → tree/filter.js} +3 -6
  104. package/src/{builtins/@first.js → tree/first.js} +2 -5
  105. package/src/{builtins/@fnTree.js → tree/fromFn.js} +3 -6
  106. package/src/{builtins/@globs.js → tree/globs.js} +3 -6
  107. package/src/tree/group.js +26 -0
  108. package/src/{builtins/@inners.js → tree/inners.js} +2 -5
  109. package/src/{builtins/@keys.js → tree/keys.js} +2 -5
  110. package/src/{builtins/@length.js → tree/length.js} +2 -2
  111. package/src/{builtins → tree}/map.d.ts +3 -6
  112. package/src/tree/map.js +154 -0
  113. package/src/{builtins/@mapFn.js → tree/mapFn.js} +14 -6
  114. package/src/{builtins/@match.js → tree/match.js} +2 -5
  115. package/src/{builtins/@merge.js → tree/merge.js} +2 -5
  116. package/src/tree/paginate.js +61 -0
  117. package/src/{builtins/@parent.js → tree/parent.js} +2 -5
  118. package/src/{builtins/@plain.js → tree/plain.js} +2 -5
  119. package/src/{builtins/@reverse.js → tree/reverse.js} +2 -5
  120. package/src/{builtins/@setDeep.js → tree/setDeep.js} +0 -3
  121. package/src/{builtins/@shuffle.js → tree/shuffle.js} +3 -9
  122. package/src/{builtins/@sortFn.js → tree/sort.js} +12 -17
  123. package/src/tree/take.js +19 -0
  124. package/src/tree/tree.js +49 -0
  125. package/src/{builtins/@values.js → tree/values.js} +2 -5
  126. package/exports/PathTransform.d.ts +0 -5
  127. package/exports/PathTransform.js +0 -20
  128. package/exports/buildExports.js +0 -112
  129. package/exports/exports.js +0 -148
  130. package/src/builtins/@builtins.js +0 -15
  131. package/src/builtins/@deepMap.js +0 -19
  132. package/src/builtins/@deepTake.js +0 -21
  133. package/src/builtins/@deepTakeFn.js +0 -21
  134. package/src/builtins/@equals.js +0 -6
  135. package/src/builtins/@exploreSite.js +0 -16
  136. package/src/builtins/@false.js +0 -1
  137. package/src/builtins/@fetch.js +0 -7
  138. package/src/builtins/@group.js +0 -20
  139. package/src/builtins/@groupFn.js +0 -33
  140. package/src/builtins/@help.js +0 -49
  141. package/src/builtins/@http.js +0 -19
  142. package/src/builtins/@https.js +0 -19
  143. package/src/builtins/@if.js +0 -28
  144. package/src/builtins/@inherited.js +0 -17
  145. package/src/builtins/@map.js +0 -19
  146. package/src/builtins/@math.js +0 -17
  147. package/src/builtins/@not.js +0 -6
  148. package/src/builtins/@or.js +0 -6
  149. package/src/builtins/@paginate.js +0 -18
  150. package/src/builtins/@paginateFn.js +0 -58
  151. package/src/builtins/@repeat.js +0 -8
  152. package/src/builtins/@sort.js +0 -23
  153. package/src/builtins/@table.js +0 -69
  154. package/src/builtins/@take.js +0 -20
  155. package/src/builtins/@takeFn.js +0 -20
  156. package/src/builtins/@tree.js +0 -4
  157. package/src/builtins/@treeHttp.js +0 -19
  158. package/src/builtins/@treeHttps.js +0 -19
  159. package/src/builtins/@true.js +0 -1
  160. package/src/builtins/mjs.handler.js +0 -2
  161. package/src/builtins/yml.handler.js +0 -2
  162. package/src/builtins/~.js +0 -9
  163. package/src/cli/showUsage.js +0 -86
  164. package/src/common/CommandModulesTransform.d.ts +0 -5
  165. package/src/common/CommandModulesTransform.js +0 -39
  166. package/src/common/arrowsMapFn.js +0 -35
  167. package/src/misc/origamiHighlightDefinition.js +0 -36
  168. /package/src/{misc → common}/assertTreeIsDefined.d.ts +0 -0
  169. /package/src/{common → dev}/ExplorableSiteTransform.d.ts +0 -0
  170. /package/src/{misc → dev}/OriCommandTransform.d.ts +0 -0
  171. /package/src/{builtins/@breakpoint.js → dev/breakpoint.js} +0 -0
  172. /package/src/{builtins/@changes.js → dev/changes.js} +0 -0
  173. /package/src/{misc → dev}/explore.css +0 -0
  174. /package/src/{builtins → handlers}/css.handler.js +0 -0
  175. /package/src/{builtins → handlers}/htm.handler.js +0 -0
  176. /package/src/{builtins → handlers}/html.handler.js +0 -0
  177. /package/src/{builtins → handlers}/jpeg.handler.js +0 -0
  178. /package/src/{builtins → handlers}/jpg.handler.js +0 -0
  179. /package/src/{builtins → handlers}/md.handler.js +0 -0
  180. /package/src/{builtins → handlers}/txt.handler.js +0 -0
  181. /package/src/{builtins → handlers}/xhtml.handler.js +0 -0
  182. /package/src/{builtins/@naturalOrder.js → origami/naturalOrder.js} +0 -0
  183. /package/src/{builtins/@post.js → origami/post.js} +0 -0
  184. /package/src/{builtins/@regexMatchFn.js → origami/regexMatchFn.js} +0 -0
  185. /package/src/{builtins/@slash.js → origami/slash.js} +0 -0
  186. /package/src/{builtins/@version.js → origami/version.js} +0 -0
  187. /package/src/{crawler → site/crawler}/crawlResources.js +0 -0
  188. /package/src/{builtins/@redirect.js → site/redirect.js} +0 -0
  189. /package/src/{builtins/@slug.js → site/slug.js} +0 -0
  190. /package/src/{builtins/@indent.js → text/indent.js} +0 -0
  191. /package/src/{common → tree}/FilterTree.js +0 -0
  192. /package/src/{common → tree}/GlobTree.js +0 -0
  193. /package/src/{common → tree}/ShuffleTransform.js +0 -0
  194. /package/src/{builtins/@calendarTree.js → tree/calendar.js} +0 -0
@@ -0,0 +1,425 @@
1
+ calc:
2
+ description: Perform math and logical operations
3
+ commands:
4
+ add:
5
+ args: (a, b, ...)
6
+ description: Add the numbers
7
+ and:
8
+ args: (a, b, ...)
9
+ description: Return true if all the arguments are true
10
+ divide:
11
+ args: (a, b)
12
+ description: Divide a by b
13
+ equals:
14
+ args: (a, b)
15
+ description: Return true if a equals b
16
+ if:
17
+ args: (a, b, c)
18
+ description: If a is true return b, otherwise c
19
+ multiply:
20
+ args: (a, b, ...)
21
+ description: Multiply the numbers
22
+ not:
23
+ args: (value)
24
+ description: Return true if a is false and vice versa
25
+ or:
26
+ args: (a, b, ...)
27
+ description: Return true if any of the arguments are true
28
+ subtract:
29
+ args: (a, b)
30
+ description: Subtract b from a
31
+
32
+ dev:
33
+ description: Develop and debug Origami projects
34
+ commands:
35
+ breakpoint:
36
+ args: (a)
37
+ description: Break into the JavaScript debugger, then return a
38
+ changes:
39
+ args: (old, new)
40
+ description: Return a tree of changes
41
+ debug:
42
+ args: (tree)
43
+ description: Add debug features to the tree
44
+ explore:
45
+ args: ()
46
+ description: Explore the current scope [when run in browser]
47
+ log:
48
+ args: (a, message)
49
+ description: Log message to the console and return a
50
+ serve:
51
+ args: (tree, port)
52
+ description: Start a web server for the tree
53
+ svg:
54
+ args: (tree, options)
55
+ description: Render a tree visually in SVG format
56
+ watch:
57
+ args: (tree, fn)
58
+ description: Reevaluate fn when tree changes
59
+
60
+ explore:
61
+ description: URL protocol to treat a website with JSON keys as a tree
62
+
63
+ files:
64
+ description: URL protocol for file system folders and files
65
+
66
+ help:
67
+ description: Get help on builtin namespaces and commands
68
+
69
+ http:
70
+ description: URL protocol for web resources via HTTP
71
+
72
+ https:
73
+ description: URL protocol for web resources via HTTPS
74
+
75
+ httpstree:
76
+ description: URL protocol for a website tree via HTTPS
77
+
78
+ httptree:
79
+ description: URL protocol for a website tree via HTTP
80
+
81
+ image:
82
+ description: Format and resize images
83
+ commands:
84
+ format:
85
+ args: (image, format, options)
86
+ description: Return the image in a different format
87
+ resize:
88
+ args: (image, options)
89
+ description: Resize the image
90
+
91
+ inherited:
92
+ description: URL protocol to get an inherited value instead of a local one
93
+
94
+ js:
95
+ description: JavaScript classes and functions
96
+ collection: true
97
+ commands:
98
+ Array:
99
+ description: JavaScript Array class
100
+ Boolean:
101
+ description: JavaScript Boolean class
102
+ Date:
103
+ description: JavaScript Date class
104
+ Error:
105
+ description: JavaScript Error class
106
+ Infinity:
107
+ description: JavaScript Infinity constant
108
+ Intl:
109
+ description: JavaScript Intl object
110
+ JSON:
111
+ description: JavaScript JSON object
112
+ Map:
113
+ description: JavaScript Map class
114
+ Math:
115
+ description: JavaScript Math object
116
+ NaN:
117
+ description: JavaScript NaN constant
118
+ Number:
119
+ description: JavaScript Number class
120
+ Object:
121
+ description: JavaScript Object class
122
+ RegExp:
123
+ description: JavaScript RegExp class
124
+ Set:
125
+ description: JavaScript Set class
126
+ String:
127
+ description: JavaScript String class
128
+ Symbol:
129
+ description: JavaScript Symbol class
130
+ decodeURI:
131
+ description: JavaScript decodeURI function
132
+ decodeURIComponent:
133
+ description: JavaScript decodeURIComponent function
134
+ encodeURI:
135
+ description: JavaScript encodeURI function
136
+ encodeURIComponent:
137
+ description: JavaScript encodeURIComponent function
138
+ "false":
139
+ description: JavaScript false constant
140
+ fetch:
141
+ description: JavaScript fetch function
142
+ isFinite:
143
+ description: JavaScript isFinite function
144
+ isNaN:
145
+ description: JavaScript isNaN function
146
+ "null":
147
+ description: JavaScript null constant
148
+ parseFloat:
149
+ description: JavaScript parseFloat function
150
+ parseInt:
151
+ description: JavaScript parseInt function
152
+ "true":
153
+ description: JavaScript true constant
154
+ undefined:
155
+ description: JavaScript undefined constant
156
+
157
+ new:
158
+ description: Create instances of JavaScript classes
159
+
160
+ node:
161
+ description: Node.js classes and modules
162
+ collection: true
163
+ commands:
164
+ Buffer:
165
+ description: Node.js Buffer class
166
+ path:
167
+ description: Node.js path module
168
+ process:
169
+ description: Node.js process object
170
+ url:
171
+ description: Node.js URL module
172
+
173
+ origami:
174
+ description: Perform general Origami language functions
175
+ commands:
176
+ basename:
177
+ args: (key)
178
+ description: Removes an extension from the key if present
179
+ builtins:
180
+ description: The set of installed builtin functions
181
+ config:
182
+ description: The current project's configuration
183
+ extension:
184
+ description: Helpers for working with file extensions
185
+ json:
186
+ args: (obj)
187
+ description: Render the object in JSON format
188
+ jsonParse:
189
+ args: (text)
190
+ description: Parse text as JSON
191
+ naturalOrder:
192
+ description: A comparison function for natural sort order
193
+ once:
194
+ args: (fn)
195
+ description: Run the function only once, return the same result
196
+ ori:
197
+ args: (text)
198
+ description: Evaluate the text as an Origami expression
199
+ post:
200
+ args: (url, data)
201
+ description: POST the given data to the URL
202
+ project:
203
+ description: The root folder for the current Origami project
204
+ regexMatch:
205
+ args: (text, regex)
206
+ description: Return matches of the regex in the text
207
+ repeat:
208
+ args: (n, obj)
209
+ description: An array of n copies of the object
210
+ shell:
211
+ args: (text)
212
+ description: Run the text as a shell command, return the output
213
+ slash:
214
+ description: Helpers for working with trailing slashes
215
+ stdin:
216
+ description: Returns the content of the standard input stream
217
+ string:
218
+ args: (obj)
219
+ description: Coerce a buffer or document to a string
220
+ toFunction:
221
+ args: (obj)
222
+ description: Coerce a tree or packed function definition to a function
223
+ unpack:
224
+ args: (buffer)
225
+ description: Unpack the buffer into a usable form
226
+ version:
227
+ args: ()
228
+ description: Return the version number of the Origami language
229
+ yaml:
230
+ args: (obj)
231
+ description: Render the object in YAML format
232
+ yamlParse:
233
+ args: (text)
234
+ description: Parse text as YAML
235
+
236
+ package:
237
+ description: URL protocol for packages installed in node_modules
238
+
239
+ scope:
240
+ description: URL protocol to explicitly reference a key in scope
241
+
242
+ site:
243
+ description: Add common website features
244
+ commands:
245
+ audit:
246
+ args: (tree)
247
+ description: Identify broken internal links and references
248
+ crawl:
249
+ args: (tree, base)
250
+ description: A tree of a site's discoverable resources
251
+ index:
252
+ args: (tree)
253
+ description: A default index.html page for the tree
254
+ jsonKeys:
255
+ args: (tree)
256
+ description: Add .keys.json files to a tree
257
+ redirect:
258
+ args: (url, options)
259
+ description: Redirect to the given URL
260
+ rss:
261
+ args: (feed)
262
+ description: Transforms a JSON Feed tree to RSS XML
263
+ sitemap:
264
+ args: (tree)
265
+ description: Generate a sitemap for the tree
266
+ slug:
267
+ args: (text)
268
+ description: A version of the text suitable for use in URLs
269
+ static:
270
+ args: (tree)
271
+ description: Define common static files for the tree
272
+
273
+ text:
274
+ description: Manipulate text
275
+ commands:
276
+ document:
277
+ args: (text, [data])
278
+ description: Create a document object with the text and data
279
+ indent:
280
+ description: Tagged template literal for normalizing indentation
281
+ inline:
282
+ args: (text)
283
+ description: Inline Origami expressions found in the text
284
+ mdHtml:
285
+ args: (markdown)
286
+ description: Render the markdown as HTML
287
+
288
+ tree:
289
+ description: Work with trees
290
+ commands:
291
+ addNextPrevious:
292
+ args: (tree)
293
+ description: Add next/previous fields to the tree's values
294
+ assign:
295
+ args: (target, source)
296
+ description: Apply key/values from source to target
297
+ cache:
298
+ args: (tree, [cache], [filter])
299
+ description: Caches values from the tree
300
+ clear:
301
+ args: (tree)
302
+ description: Remove all values from the tree
303
+ concat:
304
+ args: (...objs)
305
+ description: Concatenate text and/or trees of text
306
+ copy:
307
+ args: (source, target)
308
+ description: Copy the source tree to the target
309
+ deepMap:
310
+ args: (tree, options)
311
+ description: Map the keys and values of a deep tree
312
+ deepMerge:
313
+ args: (...trees)
314
+ description: Return a deeply-merged tree
315
+ deepReverse:
316
+ args: (tree)
317
+ description: Reverse order of keys at all levels of the tree
318
+ deepTake:
319
+ args: (tree, n)
320
+ description: The first n values from the deep tree
321
+ deepValues:
322
+ args: (tree)
323
+ description: The in-order leaf values of the tree
324
+ defineds:
325
+ args: (tree)
326
+ description: Only the defined values of the tree
327
+ entries:
328
+ args: (tree)
329
+ description: The tree's [key, value] pairs
330
+ first:
331
+ args: (tree)
332
+ description: The first value in the tree
333
+ forEach:
334
+ args: (tree, fn)
335
+ description: Apply fn to each (value, key)
336
+ from:
337
+ args: (object, options)
338
+ description: Create a tree from an object
339
+ fromFn:
340
+ args: (fn, [keys])
341
+ description: A tree defined by a value function
342
+ globs:
343
+ args: (patterns)
344
+ description: A tree whose keys can include wildcard patterns
345
+ group:
346
+ args: (tree, fn)
347
+ description: A new tree with values grouped by the function
348
+ has:
349
+ args: (tree, key)
350
+ description: True if key exists in tree
351
+ inners:
352
+ args: (tree)
353
+ description: The tree's interior nodes
354
+ isAsyncMutableTree:
355
+ args: (object)
356
+ description: True if object is an async mutable tree
357
+ isAsyncTree:
358
+ args: (object)
359
+ description: True if object is an async tree
360
+ isTraversable:
361
+ args: (object)
362
+ description: True if object is traversable
363
+ isTreelike:
364
+ args: (object)
365
+ description: True if object can be coerced to a tree
366
+ keys:
367
+ args: (tree)
368
+ description: The keys of the tree
369
+ length:
370
+ args: (tree)
371
+ description: The tree's size (number of keys)
372
+ map:
373
+ args: (tree, options)
374
+ description: Create a new tree by mapping keys and/or values
375
+ mapReduce:
376
+ args: (tree, valueFn, reduceFn)
377
+ description: Map values and reduce them
378
+ match:
379
+ args: (pattern, fn, [keys])
380
+ description: Matches simple patterns or regular expressions
381
+ merge:
382
+ args: (...trees)
383
+ description: Return a new tree merging the given trees
384
+ paginate:
385
+ args: (tree, [n])
386
+ description: Group the tree's values into fixed-size sets
387
+ parent:
388
+ args: (tree)
389
+ description: The parent of the given tree node
390
+ paths:
391
+ args: (tree)
392
+ description: Slash-separated paths for the tree's values
393
+ plain:
394
+ args: (tree)
395
+ description: Render the tree as a plain JavaScript object
396
+ remove:
397
+ args: (tree, key)
398
+ description: Remove the value for the key from tree
399
+ reverse:
400
+ args: (tree)
401
+ description: Reverse the order of the tree's keys
402
+ setDeep:
403
+ args: (target, source)
404
+ description: Applies the source tree to the target
405
+ shuffle:
406
+ args: (tree)
407
+ description: Shuffle the keys of the tree
408
+ sort:
409
+ args: (tree, options)
410
+ description: A new tree with its keys sorted
411
+ take:
412
+ args: (tree, n)
413
+ description: The first n values in the tree
414
+ traverse:
415
+ args: (tree, ...keys)
416
+ description: Return the value at the path of keys
417
+ traverseOrThrow:
418
+ args: (tree, ...keys)
419
+ description: Return the value at the path of keys or throw
420
+ traversePath:
421
+ args: (tree, path)
422
+ description: Traverse a slash-separated path
423
+ values:
424
+ args: (tree)
425
+ description: The tree's values
@@ -1,4 +1,4 @@
1
- import assertTreeIsDefined from "../../misc/assertTreeIsDefined.js";
1
+ import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
2
2
  import imageFormatFn from "./formatFn.js";
3
3
 
4
4
  /**
@@ -13,6 +13,6 @@ import imageFormatFn from "./formatFn.js";
13
13
  * @param {any} options
14
14
  */
15
15
  export default async function imageFormat(input, format, options) {
16
- assertTreeIsDefined(this, "image/format");
16
+ assertTreeIsDefined(this, "image:format");
17
17
  return imageFormatFn.call(this, format, options)(input);
18
18
  }
@@ -1,5 +1,5 @@
1
1
  import sharp from "sharp";
2
- import assertTreeIsDefined from "../../misc/assertTreeIsDefined.js";
2
+ import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
3
3
 
4
4
  /**
5
5
  * Return a function that transforms an input image to a different format.
@@ -0,0 +1,2 @@
1
+ export { default as format } from "./format.js";
2
+ export { default as resize } from "./resize.js";
@@ -1,4 +1,4 @@
1
- import assertTreeIsDefined from "../../misc/assertTreeIsDefined.js";
1
+ import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
2
2
  import imageResizeFn from "./resizeFn.js";
3
3
 
4
4
  /**
@@ -9,6 +9,6 @@ import imageResizeFn from "./resizeFn.js";
9
9
  * @param {import("sharp").ResizeOptions} options
10
10
  */
11
11
  export default async function resize(input, options) {
12
- assertTreeIsDefined(this, "image/resize");
12
+ assertTreeIsDefined(this, "image:resize");
13
13
  return imageResizeFn.call(this, options)(input);
14
14
  }
@@ -1,5 +1,5 @@
1
1
  import sharp from "sharp";
2
- import assertTreeIsDefined from "../../misc/assertTreeIsDefined.js";
2
+ import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
3
3
 
4
4
  /**
5
5
  * Return a function that resizes an image.
@@ -0,0 +1,24 @@
1
+ //
2
+ // This library includes a number of modules with circular dependencies. This
3
+ // module exists to explicitly set the loading order for those modules. To
4
+ // enforce use of this loading order, other modules should only load the modules
5
+ // below via this module.
6
+ //
7
+ // About this pattern:
8
+ // https://medium.com/visual-development/how-to-fix-nasty-circular-dependency-issues-once-and-for-all-in-javascript-typescript-a04c987cf0de
9
+ //
10
+ // Note: to avoid having VS Code auto-sort the imports, keep lines between them.
11
+
12
+ export { default as jsHandler } from "./handlers/js.handler.js";
13
+
14
+ export { default as oriHandler } from "./handlers/ori.handler.js";
15
+
16
+ export { default as oridocumentHandler } from "./handlers/oridocument.handler.js";
17
+
18
+ export { default as processUnpackedContent } from "./common/processUnpackedContent.js";
19
+
20
+ export { default as wasmHandler } from "./handlers/wasm.handler.js";
21
+
22
+ export { default as yamlHandler } from "./handlers/yaml.handler.js";
23
+
24
+ export { default as builtinsTree } from "./builtinsTree.js";
@@ -1,4 +1,9 @@
1
- const js = {
1
+ async function fetchWrapper(resource, options) {
2
+ const response = await fetch(resource, options);
3
+ return response.ok ? await response.arrayBuffer() : undefined;
4
+ }
5
+
6
+ export default {
2
7
  Array,
3
8
  Boolean,
4
9
  Date,
@@ -20,6 +25,7 @@ const js = {
20
25
  encodeURI,
21
26
  encodeURIComponent,
22
27
  false: false,
28
+ fetch: fetchWrapper,
23
29
  isFinite,
24
30
  isNaN,
25
31
  null: null,
@@ -28,8 +34,3 @@ const js = {
28
34
  true: true,
29
35
  undefined: undefined,
30
36
  };
31
-
32
- js.usage = "@js\tAccess JavaScript classes and utility functions";
33
- js.documentation = "https://weborigami.org/language/@js.html";
34
-
35
- export default js;
@@ -14,14 +14,9 @@ const patchedProcess = Object.create(null, {
14
14
  },
15
15
  });
16
16
 
17
- const node = {
17
+ export default {
18
18
  Buffer,
19
19
  path,
20
20
  process: patchedProcess,
21
21
  url,
22
22
  };
23
-
24
- node.usage = "@node\tAccess Node classes and utility functions";
25
- node.documentation = "https://weborigami.org/language/@node.html";
26
-
27
- export default node;
@@ -1,6 +1,6 @@
1
- import { extname } from "@weborigami/language";
1
+ import { extension } from "@weborigami/async-tree";
2
2
 
3
3
  export default function basename(key) {
4
- const ext = extname(key);
4
+ const ext = extension.extname(key);
5
5
  return ext ? key.slice(0, -ext.length) : key;
6
6
  }
@@ -1,4 +1,4 @@
1
- import project from "./@project.js";
1
+ import project from "./project.js";
2
2
 
3
3
  /**
4
4
  * Return the configuration for the current project.
@@ -18,6 +18,3 @@ export default async function config(key) {
18
18
  const parent = projectTree.parent;
19
19
  return key === undefined ? parent : parent.get(key);
20
20
  }
21
-
22
- config.usage = `@config\tThe current project's configuration tree`;
23
- config.documentation = "https://weborigami.org/language/@config.html";
@@ -1,6 +1,6 @@
1
1
  /** @typedef {import("@weborigami/types").AsyncTree} AsyncTree */
2
2
  import { isUnpackable, toPlainValue } from "@weborigami/async-tree";
3
- import assertTreeIsDefined from "../misc/assertTreeIsDefined.js";
3
+ import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
4
4
 
5
5
  /**
6
6
  * Render the given object in JSON format.
@@ -9,7 +9,7 @@ import assertTreeIsDefined from "../misc/assertTreeIsDefined.js";
9
9
  * @param {any} [obj]
10
10
  */
11
11
  export default async function json(obj) {
12
- assertTreeIsDefined(this, "json");
12
+ assertTreeIsDefined(this, "origami:json");
13
13
  // A fragment of the logic from getTreeArgument.js
14
14
  if (arguments.length > 0 && obj === undefined) {
15
15
  throw new Error(
@@ -26,6 +26,3 @@ export default async function json(obj) {
26
26
  const value = await toPlainValue(obj);
27
27
  return JSON.stringify(value, null, 2);
28
28
  }
29
-
30
- json.usage = "@json <obj>\tRender the object as text in JSON format";
31
- json.documentation = "https://weborigami.org/builtins/@json.html";
@@ -4,6 +4,3 @@ export default async function jsonParse(input) {
4
4
  const text = toString(input);
5
5
  return text ? JSON.parse(text) : undefined;
6
6
  }
7
-
8
- jsonParse.usage = `@jsonParse <text>\tParse text as JSON`;
9
- jsonParse.documentation = "https://weborigami.org/builtins/@jsonParse.html";
@@ -1,4 +1,4 @@
1
- import assertTreeIsDefined from "../misc/assertTreeIsDefined.js";
1
+ import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
2
2
 
3
3
  const fnPromiseMap = new WeakMap();
4
4
 
@@ -10,7 +10,7 @@ const fnPromiseMap = new WeakMap();
10
10
  * @param {Function} fn
11
11
  */
12
12
  export default async function once(fn) {
13
- assertTreeIsDefined(this, "once");
13
+ assertTreeIsDefined(this, "origami:once");
14
14
  if (!fnPromiseMap.has(fn)) {
15
15
  fnPromiseMap.set(fn, fn.call(this));
16
16
  }
@@ -4,9 +4,9 @@ import {
4
4
  toString,
5
5
  } from "@weborigami/async-tree";
6
6
  import { compile } from "@weborigami/language";
7
- import builtins from "../builtins/@builtins.js";
7
+ import builtinsTree from "../builtinsTree.js";
8
+ import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
8
9
  import { toYaml } from "../common/serialize.js";
9
- import assertTreeIsDefined from "../misc/assertTreeIsDefined.js";
10
10
 
11
11
  const TypedArray = Object.getPrototypeOf(Uint8Array);
12
12
 
@@ -23,13 +23,13 @@ export default async function ori(
23
23
  expression,
24
24
  options = { formatResult: true }
25
25
  ) {
26
- assertTreeIsDefined(this, "ori");
26
+ assertTreeIsDefined(this, "origami:ori");
27
27
 
28
28
  // In case expression has come from a file, cast it to a string.
29
29
  expression = toString(expression);
30
30
 
31
31
  // Run in the context of `this` if defined, otherwise use the builtins.
32
- const tree = this ?? builtins;
32
+ const tree = this ?? builtinsTree;
33
33
 
34
34
  // Compile the expression. Avoid caching scope references so that, e.g.,
35
35
  // passing a function to the `watch` builtin will always look the current
@@ -91,6 +91,3 @@ async function formatResult(result) {
91
91
 
92
92
  return text;
93
93
  }
94
-
95
- ori.usage = `@ori <text>\tEvaluates the text as an Origami expression`;
96
- ori.documentation = "https://weborigami.org/language/@ori.html";
@@ -0,0 +1,29 @@
1
+ // Use a dynamic import to avoid circular dependencies
2
+ export const builtins = import("../internal.js").then(
3
+ (internal) => internal.builtinsTree
4
+ );
5
+
6
+ export { extension } from "@weborigami/async-tree";
7
+ export { toFunction } from "../common/utilities.js";
8
+
9
+ export { default as help } from "../help/help.js"; // Alias
10
+ export { default as basename } from "./basename.js";
11
+ export { default as config } from "./config.js";
12
+ export { default as json } from "./json.js";
13
+ export { default as jsonParse } from "./jsonParse.js";
14
+ export { default as naturalOrder } from "./naturalOrder.js";
15
+ export { default as once } from "./once.js";
16
+ export { default as ori } from "./ori.js";
17
+ export { default as pack } from "./pack.js";
18
+ export { default as post } from "./post.js";
19
+ export { default as project } from "./project.js";
20
+ export { default as regexMatch } from "./regexMatch.js";
21
+ export { default as repeat } from "./repeat.js";
22
+ export { default as shell } from "./shell.js";
23
+ export { default as slash } from "./slash.js";
24
+ export { default as stdin } from "./stdin.js";
25
+ export { default as string } from "./string.js";
26
+ export { default as unpack } from "./unpack.js";
27
+ export { default as version } from "./version.js";
28
+ export { default as yaml } from "./yaml.js";
29
+ export { default as yamlParse } from "./yamlParse.js";
@@ -1,4 +1,4 @@
1
- import assertTreeIsDefined from "../misc/assertTreeIsDefined.js";
1
+ import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
2
2
 
3
3
  /**
4
4
  * @typedef {import("@weborigami/types").AsyncTree} AsyncTree
@@ -8,6 +8,6 @@ import assertTreeIsDefined from "../misc/assertTreeIsDefined.js";
8
8
  * @returns
9
9
  */
10
10
  export default function pack(obj) {
11
- assertTreeIsDefined(this, "pack");
11
+ assertTreeIsDefined(this, "origami:pack");
12
12
  return obj?.pack?.();
13
13
  }