jtlt 0.3.0 → 0.4.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 (40) hide show
  1. package/CHANGES.md +9 -0
  2. package/README.md +46 -78
  3. package/demo/codemirror.esm.js +28242 -0
  4. package/demo/codemirror.js +94 -0
  5. package/demo/index.css +7 -0
  6. package/demo/index.html +11 -14
  7. package/demo/index.js +206 -26
  8. package/demo/vendor/jamilih/dist/jml.mjs +2341 -0
  9. package/demo/vendor/jhtml/src/SAJJ/SAJJ.ObjectArrayDelegator.js +356 -0
  10. package/demo/vendor/jhtml/src/SAJJ/SAJJ.Stringifier.js +186 -0
  11. package/demo/vendor/jhtml/src/SAJJ/SAJJ.js +746 -0
  12. package/demo/vendor/jhtml/src/SAJJ/testing/SAJJ.html +33 -0
  13. package/demo/vendor/jhtml/src/SAJJ/testing/SAJJ.testing.js +25 -0
  14. package/demo/vendor/jhtml/src/jhtml-browser.js +5 -0
  15. package/demo/vendor/jhtml/src/jhtml-node.cts +3 -0
  16. package/demo/vendor/jhtml/src/jhtml-node.js +8 -0
  17. package/demo/vendor/jhtml/src/jhtml-node.mts +1 -0
  18. package/demo/vendor/jhtml/src/jhtml.cts +3 -0
  19. package/demo/vendor/jhtml/src/jhtml.js +602 -0
  20. package/demo/vendor/jhtml/src/jhtml.mts +1 -0
  21. package/demo/vendor/jsonpath-plus/dist/index-browser-esm.js +2158 -0
  22. package/demo/vendor/simple-get-json/dist/index-es.js +151 -0
  23. package/dist/JSONPathTransformerContext.d.ts +88 -4
  24. package/dist/JSONPathTransformerContext.d.ts.map +1 -1
  25. package/dist/XPathTransformer.d.ts +2 -2
  26. package/dist/XPathTransformerContext.d.ts +92 -8
  27. package/dist/XPathTransformerContext.d.ts.map +1 -1
  28. package/dist/index.d.ts +4 -4
  29. package/dist/index.d.ts.map +1 -1
  30. package/docs/API.expanded.md +5 -3
  31. package/docs/API.md +1 -1
  32. package/docs/TO-DO.md +55 -31
  33. package/eslint.config.js +3 -1
  34. package/package.json +24 -4
  35. package/rollup.config.js +13 -0
  36. package/src/JSONPathTransformerContext.js +422 -4
  37. package/src/XPathTransformer.js +1 -1
  38. package/src/XPathTransformerContext.js +462 -11
  39. package/src/index.js +9 -6
  40. package/tsconfig.json +5 -2
package/docs/TO-DO.md CHANGED
@@ -1,6 +1,8 @@
1
1
  ## To-dos
2
2
 
3
- 1. Document and add test cases to cover current features! (Could adapt an XSLT/XQuery test suite)
3
+ 1. Testing: Could adapt an XSLT/XQuery test suite
4
+
5
+ 1. Document
4
6
 
5
7
  1. Implement and demo equivalent to applying and calling templates, and
6
8
  root template
@@ -10,45 +12,41 @@
10
12
  even making aliases so that XQuery's friendlier terms can be used
11
13
  instead of XSLT's.
12
14
 
13
- 2. Support processing of JSON documents with `$jtlt-stylesheet` to let
14
- documents define their own targeted stylesheets.
15
+ 2. Support processing of JSON documents with `$jtlt-stylesheet` to let
16
+ documents define their own targeted stylesheets and make own
17
+ `<?xml-stylesheet type="text/javascript" href="..."?>` for XML
15
18
 
16
- 3. When sufficiently documented, add as example library/tool to
19
+ 3. When sufficiently documented, add as example library/tool to
17
20
  JSONPath wiki.
18
21
 
19
- 4. Allow alternative to `element()`, `array()`, etc. methods by just
22
+ 4. Allow alternative to `element()`, `array()`, etc. methods by just
20
23
  detecting those types from return values (and generic of each
21
24
  type like `dom()` and `json()`).
22
25
 
23
- 5. Allow, depending on mode, containers to contain containers of other
26
+ 5. Allow, depending on mode, containers to contain containers of other
24
27
  types (e.g., a JS container containing DOM objects, or temporary use
25
28
  of a string container, etc.).
26
29
 
27
- 1. Support XML and add [hXML](https://github.com/brettz9/hxml) methods.
28
-
29
- 2. Support [JHTML](https://github.com/brettz9/jhtml).
30
+ 1. Support XML and add [hXML](https://github.com/brettz9/hxml) methods.
30
31
 
31
- 3. Support `appendJSON()`/`appendDOM()` and
32
+ 2. Support `appendJSON()`/`appendDOM()` and
32
33
  `appendType('json', ...)` (allowing type extensions).
33
34
 
34
- 6. Add `appendResult(function () {return result})`.
35
+ 6. Add `appendResult(function () {return result})`.
35
36
 
36
- 7. Add JSON update functions (equivalent to Xquery Update Facility for
37
+ 7. Add JSON update functions (equivalent to Xquery Update Facility for
37
38
  XML ([overview](http://www.xmlplease.com/xquery-update))) and create
38
39
  JSON serialization (as with XSLT expressed itself in declarative XML)
39
40
  so one can submit and evaluate
40
41
  through [HTTPQuery](https://github.com/brettz9/httpquery) (and also
41
42
  supply to JSONEditor, etc.). Utilize updating by reference.
42
43
 
43
- 8. Demo narrowing to subset of JavaScript (as with `jspe`) to make
44
+ 8. Demo narrowing to subset of JavaScript (as with `jsep`) to make
44
45
  JTLT truly "declarative" as far as freedom from scripting
45
46
 
46
- 9. Use [fontoxpath](https://github.com/FontoXML/fontoxpath)
47
- for XPath 3.1 implementation?
48
-
49
47
  ## Possible to-dos
50
48
 
51
- 1. Make schema-aware so that templates could target types. Most reusable
49
+ 1. Make schema-aware so that templates could target types. Most reusable
52
50
  application may be having a type-driven view of a JSON Schema instance
53
51
  (e.g., dates could be shown inside a calendar widget). Perhaps this
54
52
  schema-awareness could also drive a JSON editor (as with other existing
@@ -59,21 +57,18 @@
59
57
  files) could point the way for edited contents to be saved back to the
60
58
  correct JSON file and position in the JSON file.
61
59
 
62
- 2. Add a [non-eval PR for JSONPath](https://github.com/s3u/JSONPath/pull/4).
60
+ 2. ~~Add a [non-eval PR for JSONPath](https://github.com/s3u/JSONPath/pull/4).~~
63
61
  The OR condition (outside of filters) is another important feature as
64
62
  would be schema-aware path results.
65
63
 
66
- 3. Allow hybrid JSON/[Jamilih](https://github.com/brettz9/jamilih) or
64
+ 3. Allow hybrid JSON/[Jamilih](https://github.com/brettz9/jamilih) or
67
65
  JSON/(X)HTML/XML so that one can add
68
66
  XPath or query into HTML in a relevant manner
69
67
 
70
- 4. Support pull parsing/streaming? Pass `done()` function to templates to
68
+ 4. Support pull parsing/streaming? Pass `done()` function to templates to
71
69
  signal completion?
72
70
 
73
- 5. Support Promise API in addition to callbacks (reconcile with
74
- current chaining; see also XQuery FLWOR to-do)
75
-
76
- 6. Add [XQuery Functions](https://code.google.com/p/jsxqueryparser/source/browse/trunk/jsxqueryparser/XQueryParser.js#1768)
71
+ 5. Add [XQuery Functions](https://code.google.com/p/jsxqueryparser/source/browse/trunk/jsxqueryparser/XQueryParser.js#1768)
77
72
  (also supporting DOM and JSON where possible) as plug-in (also any
78
73
  missing from XSLT/XQuery 3.0). Also add, if not present among these
79
74
  functions (or in XQuery), add equivalents to XSLT's
@@ -82,49 +77,74 @@
82
77
  iterating or retrieving IndexedDB, `localStorage`, and cookies
83
78
  (names, keys and values).
84
79
 
85
- 7. Add `outputType` which uses a DOM joiner but allows specialized
80
+ 6. Add `outputType` which uses a DOM joiner but allows specialized
86
81
  serialized output (e.g., pretty-printed HTML) so the users
87
82
  don't need to build it themselves (likewise with stringified
88
83
  JSON output).
89
84
 
90
- 8. See code for other possible to-dos
85
+ 7. See code for other possible to-dos
91
86
 
92
- 9. Consider implementing the following elements from <https://www.w3.org/TR/xslt20/>
87
+ 8. Consider implementing the following elements from <https://www.w3.org/TR/xslt-30/>
93
88
  which are not yet implemented.
94
89
 
95
- "xsl:analyze-string",
90
+ xsl:accept
91
+ xsl:accumulator
92
+ xsl:accumulator-rule
93
+ ~~"xsl:analyze-string",~~
96
94
  "xsl:apply-imports",
97
95
  ~~"xsl:apply-templates",~~
96
+ xsl:assert
98
97
  ~~"xsl:attribute",~~
99
98
  "xsl:attribute-set",
99
+ xsl:break
100
100
  ~~"xsl:call-template",~~
101
+ xsl:catch
101
102
  "xsl:character-map",
102
103
  ~~"xsl:choose",~~
103
104
  ~~"xsl:comment",~~
105
+ xsl:context-item
104
106
  ~~"xsl:copy",~~
105
107
  ~~"xsl:copy-of",~~
106
108
  "xsl:decimal-format",
107
109
  ~~"xsl:document",~~
108
110
  ~~"xsl:element",~~
111
+ xsl:evaluate
112
+ xsl:expose
109
113
  "xsl:fallback",
110
114
  ~~"xsl:for-each",~~
111
115
  "xsl:for-each-group",
116
+ xsl:fork
112
117
  "xsl:function",
118
+ xsl:global-context-item
113
119
  ~~"xsl:if",~~
114
120
  "xsl:import",
115
121
  "xsl:import-schema",
116
122
  "xsl:include",
123
+ xsl:iterate
117
124
  ~~"xsl:key",~~
118
- "xsl:matching-substring",
125
+ xsl:map
126
+ xsl:map-entry
127
+ ~~"xsl:matching-substring",~~
128
+ xsl:merge
129
+ xsl:merge-action
130
+ xsl:merge-key
131
+ xsl:merge-source
119
132
  ~~"xsl:message",~~
133
+ xsl:mode
120
134
  "xsl:namespace",
121
135
  "xsl:namespace-alias",
136
+ xsl:next-iteration
122
137
  "xsl:next-match",
123
- "xsl:non-matching-substring",
124
- "xsl:number",
138
+ ~~"xsl:non-matching-substring",~~
139
+ ~~"xsl:number",~~
140
+ xsl:on-completion
141
+ xsl:on-empty
142
+ xsl:on-non-empty
125
143
  ~~"xsl:otherwise",~~
126
144
  ~~"xsl:output",~~
127
145
  "xsl:output-character",
146
+ xsl:override
147
+ xsl:package
128
148
  "xsl:param",
129
149
  "xsl:perform-sort",
130
150
  "xsl:preserve-space",
@@ -132,13 +152,17 @@
132
152
  ~~"xsl:result-document",~~
133
153
  "xsl:sequence",
134
154
  ~~"xsl:sort",~~
155
+ xsl:source-document
135
156
  "xsl:strip-space",
136
157
  ~~"xsl:stylesheet",~~
137
158
  ~~"xsl:template",~~
138
159
  ~~"xsl:text",~~
139
160
  ~~"xsl:transform",~~
161
+ xsl:try
162
+ xsl:use-package
140
163
  ~~"xsl:value-of",~~
141
164
  ~~"xsl:variable",~~
142
165
  ~~"xsl:when",~~
166
+ xsl:where-populated
143
167
  ~~"xsl:with-param"~~
144
168
 
package/eslint.config.js CHANGED
@@ -4,7 +4,9 @@ export default [
4
4
  {
5
5
  ignores: [
6
6
  'dist',
7
- 'coverage'
7
+ 'coverage',
8
+ 'demo/vendor',
9
+ 'demo/codemirror.esm.js'
8
10
  ]
9
11
  },
10
12
  ...ashNazg(['sauron']),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jtlt",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "author": "Brett Zamir",
6
6
  "contributors": [],
@@ -25,16 +25,28 @@
25
25
  "url": "https://github.com/brettz9/jtlt.git"
26
26
  },
27
27
  "dependencies": {
28
+ "@codemirror/lang-javascript": "^6.2.4",
29
+ "@codemirror/lang-json": "^6.0.2",
30
+ "@codemirror/lang-xml": "^6.1.0",
31
+ "@codemirror/language": "^6.11.3",
32
+ "@codemirror/state": "^6.5.2",
33
+ "@lezer/highlight": "^1.2.3",
34
+ "codemirror": "^6.0.2",
35
+ "fontoxpath": "^3.33.2",
28
36
  "jamilih": "0.62.1",
29
37
  "jhtml": "0.7.1",
30
38
  "jsdom": "27.1.0",
31
39
  "jsonpath-plus": "10.3.0",
40
+ "prsc": "^4.0.0",
32
41
  "simple-get-json": "10.0.0",
33
- "xpath2.js": "1.0.0-alpha-6"
42
+ "whynot": "^5.0.0",
43
+ "xpath2.js": "1.0.0-alpha-6",
44
+ "xspattern": "^3.1.0"
34
45
  },
35
46
  "devDependencies": {
36
47
  "@arethetypeswrong/cli": "^0.18.2",
37
48
  "@node-static/node-static": "^0.8.1",
49
+ "@rollup/plugin-node-resolve": "^16.0.3",
38
50
  "@types/chai": "^5.2.3",
39
51
  "@types/jsdom": "^27.0.0",
40
52
  "@types/mocha": "^10.0.10",
@@ -44,6 +56,7 @@
44
56
  "eslint-config-ash-nazg": "^39.8.0",
45
57
  "mocha": "^11.7.5",
46
58
  "open": "^10.2.0",
59
+ "rollup": "^4.53.2",
47
60
  "typescript": "^5.9.3"
48
61
  },
49
62
  "bugs": "https://github.com/brettz9/jtlt/issues",
@@ -55,12 +68,19 @@
55
68
  "javascript"
56
69
  ],
57
70
  "scripts": {
58
- "start": "open http://localhost:8020/demo/ && static -p 8020",
71
+ "start": "open http://localhost:8021/demo/ && static -p 8021",
59
72
  "attw": "attw --pack",
60
73
  "tsc": "tsc",
61
- "build": "tsc -p tsconfig-prod.json",
74
+ "build": "tsc -p tsconfig-prod.json && npm run rollup",
75
+ "rollup": "rollup -c",
76
+ "copy-simple-get-json": "cp -r node_modules/simple-get-json/dist/index-es.js demo/vendor/simple-get-json/dist/index-es.js",
77
+ "copy-jhtml": "cp -Rf node_modules/jhtml/src demo/vendor/jhtml",
78
+ "copy-jamilih": "cp node_modules/jamilih/dist/jml.mjs demo/vendor/jamilih/dist/jml.mjs",
79
+ "copy-jsonpath-plus": "cp node_modules/jsonpath-plus/dist/index-browser-esm.js demo/vendor/jsonpath-plus/dist/index-browser-esm.js",
80
+ "copy": "npm run copy-simple-get-json && npm run copy-jhtml && npm run copy-jamilih && npm run copy-jsonpath-plus",
62
81
  "lint": "eslint .",
63
82
  "mocha": "mocha",
83
+ "test:browser": "open http://localhost:8020/test/browser/ && static -p 8020",
64
84
  "test": "c8 npm run mocha"
65
85
  }
66
86
  }
@@ -0,0 +1,13 @@
1
+ import {nodeResolve} from '@rollup/plugin-node-resolve';
2
+
3
+ export default {
4
+ input: 'demo/codemirror.js',
5
+ output: {
6
+ file: 'demo/codemirror.esm.js',
7
+ format: 'esm',
8
+ banner: '// Do not edit this file; it was auto-generated'
9
+ },
10
+ plugins: [
11
+ nodeResolve()
12
+ ]
13
+ };