@thomas.f/prnext 0.1.19-alpha → 0.1.21-alpha

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 (113) hide show
  1. package/build/app.mjs +46 -78
  2. package/build/build-lock.mjs +2 -71
  3. package/build/build-retention.mjs +119 -0
  4. package/build/build-timings.mjs +38 -0
  5. package/build/bundle-runtime.mjs +17 -16
  6. package/build/cache-command.mjs +31 -0
  7. package/build/check.mjs +41 -3
  8. package/build/compilation-cache.mjs +32 -12
  9. package/build/compilation-storage.mjs +190 -0
  10. package/build/compiler.mjs +5 -4
  11. package/build/config.mjs +23 -2
  12. package/build/create.mjs +1 -1
  13. package/build/css-modules.mjs +4 -0
  14. package/build/dev-action-graph.mjs +21 -0
  15. package/build/flight-summary.mjs +64 -0
  16. package/build/font-cache.mjs +9 -6
  17. package/build/font-files.mjs +1 -1
  18. package/build/index.mjs +57 -36
  19. package/build/inspect.mjs +3 -0
  20. package/build/inspection-summary.mjs +7 -2
  21. package/build/native-discovery.mjs +18 -6
  22. package/build/native-ppr.mjs +32 -0
  23. package/build/npm-packages.mjs +2 -2
  24. package/build/og.mjs +121 -1
  25. package/build/parallel-plan.mjs +55 -0
  26. package/build/persistent-cache.mjs +29 -24
  27. package/build/production-check.mjs +34 -0
  28. package/build/react-compiler-report.mjs +31 -8
  29. package/build/react-compiler.mjs +101 -10
  30. package/build/server-config.mjs +35 -0
  31. package/build/source-analysis.mjs +108 -5
  32. package/build/standalone-copy.mjs +48 -0
  33. package/build/standalone.mjs +2 -22
  34. package/build/static-adapter.mjs +7 -3
  35. package/build/transform-cache.mjs +17 -3
  36. package/build/transform.mjs +38 -6
  37. package/build/typescript-dev.mjs +3 -1
  38. package/cli.mjs +27 -5
  39. package/compat/app-layout-context.cjs +7 -3
  40. package/compat/diagnostics.cjs +5 -4
  41. package/compat/flight-delta.cjs +47 -12
  42. package/compat/index.d.ts +24 -1
  43. package/compat/navigation-authorization.cjs +8 -1
  44. package/compat/runtime-sample.cjs +56 -0
  45. package/compat/use-cache.cjs +5 -2
  46. package/docs/ai/compatibility.md +113 -10
  47. package/docs/ai/deployment.md +144 -0
  48. package/docs/ai/quickstart.md +5 -0
  49. package/docs/ai/troubleshooting.md +22 -0
  50. package/package.json +25 -22
  51. package/release/fontkit.mjs +31 -0
  52. package/release/verify.mjs +3 -0
  53. package/runtime/api.mjs +5 -2
  54. package/runtime/app-client.mjs +246 -54
  55. package/runtime/app-partial.mjs +2 -10
  56. package/runtime/app-prefetch.mjs +2 -2
  57. package/runtime/app-render.mjs +42 -13
  58. package/runtime/app-stream-channel.mjs +20 -6
  59. package/runtime/app-stream-html.mjs +30 -11
  60. package/runtime/app-styles.mjs +22 -4
  61. package/runtime/cache-components-rsc.mjs +26 -6
  62. package/runtime/cache-result.mjs +58 -0
  63. package/runtime/compile-cache-retention.mjs +53 -0
  64. package/runtime/compile-cache.mjs +28 -1
  65. package/runtime/dev-client.mjs +32 -8
  66. package/runtime/dev-compiler-broker.mjs +20 -23
  67. package/runtime/dev-gateway.mjs +23 -6
  68. package/runtime/dev-route-selection.mjs +64 -0
  69. package/runtime/dev-runtime-pool.mjs +3 -2
  70. package/runtime/dev-runtime-spare.mjs +1 -1
  71. package/runtime/dev-session-retention.mjs +154 -0
  72. package/runtime/development-flight.mjs +59 -0
  73. package/runtime/development-queue.mjs +33 -0
  74. package/runtime/development.mjs +37 -16
  75. package/runtime/env.mjs +9 -0
  76. package/runtime/flight-delta.mjs +31 -5
  77. package/runtime/flight-diagnostics.mjs +48 -0
  78. package/runtime/flight-tap.mjs +10 -5
  79. package/runtime/html-envelope.mjs +34 -0
  80. package/runtime/loopback-rpc.mjs +92 -0
  81. package/runtime/native-ppr.mjs +88 -0
  82. package/runtime/og/NOTICE.txt +1 -1
  83. package/runtime/og/index.node.mjs +76 -31216
  84. package/runtime/og/upstream.json +115 -0
  85. package/runtime/persistent/client.mjs +5 -3
  86. package/runtime/persistent/common.mjs +7 -18
  87. package/runtime/persistent/daemon.mjs +4 -12
  88. package/runtime/persistent/health.mjs +58 -0
  89. package/runtime/persistent/native-proxy.mjs +1 -1
  90. package/runtime/persistent/watchdog.mjs +12 -27
  91. package/runtime/prewarm.mjs +35 -0
  92. package/runtime/project-lock.mjs +71 -0
  93. package/runtime/request-transport.mjs +112 -32
  94. package/runtime/rsc-worker.mjs +58 -8
  95. package/runtime/storage-path.mjs +36 -0
  96. package/runtime/trace.mjs +44 -4
  97. package/runtime/worker.mjs +37 -17
  98. package/vendor/fontkit/NOTICE.txt +5 -0
  99. package/vendor/fontkit/SOURCE-NOTICES.txt +209 -0
  100. package/vendor/fontkit/index.mjs +3 -0
  101. package/vendor/fontkit/licenses/@swc__helpers/LICENSE +201 -0
  102. package/vendor/fontkit/licenses/base64-js/LICENSE +21 -0
  103. package/vendor/fontkit/licenses/brotli/readme.md +61 -0
  104. package/vendor/fontkit/licenses/clone/LICENSE +18 -0
  105. package/vendor/fontkit/licenses/dfa/README.md +83 -0
  106. package/vendor/fontkit/licenses/fast-deep-equal/LICENSE +21 -0
  107. package/vendor/fontkit/licenses/fontkit/README.md +266 -0
  108. package/vendor/fontkit/licenses/restructure/LICENSE +21 -0
  109. package/vendor/fontkit/licenses/tiny-inflate/LICENSE +21 -0
  110. package/vendor/fontkit/licenses/tslib/LICENSE.txt +12 -0
  111. package/vendor/fontkit/licenses/unicode-properties/LICENSE +8 -0
  112. package/vendor/fontkit/licenses/unicode-trie/LICENSE +8 -0
  113. package/vendor/fontkit/upstream.json +215 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2024 SWC contributors.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Jameson Little
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,61 @@
1
+ # Brotli.js
2
+
3
+ Brotli.js is port of the [Brotli](http://tools.ietf.org/html/draft-alakuijala-brotli-01) compression algorithm (as used in the [WOFF2](http://www.w3.org/TR/WOFF2/) font format) to JavaScript. The decompressor is hand ported, and the compressor is ported
4
+ with Emscripten. The original C++ source code can be found [here](http://github.com/google/brotli).
5
+
6
+ ## Installation and usage
7
+
8
+ Install using npm.
9
+
10
+ npm install brotli
11
+
12
+ If you want to use brotli in the browser, you should use [Browserify](http://browserify.org/) to build it.
13
+
14
+ In node, or in browserify, you can load brotli in the standard way:
15
+
16
+ ```javascript
17
+ var brotli = require('brotli');
18
+ ```
19
+
20
+ You can also require just the `decompress` function or just the `compress` function, which is useful for browserify builds.
21
+ For example, here's how you'd require just the `decompress` function.
22
+
23
+ ```javascript
24
+ var decompress = require('brotli/decompress');
25
+ ```
26
+
27
+ ## API
28
+
29
+ ### brotli.decompress(buffer, [outSize])
30
+
31
+ Decompresses the given buffer to produce the original input to the compressor.
32
+ The `outSize` parameter is optional, and will be computed by the decompressor
33
+ if not provided. Inside a WOFF2 file, this can be computed from the WOFF2 directory.
34
+
35
+ ```javascript
36
+ // decode a buffer where the output size is known
37
+ brotli.decompress(compressedData, uncompressedLength);
38
+
39
+ // decode a buffer where the output size is not known
40
+ brotli.decompress(fs.readFileSync('compressed.bin'));
41
+ ```
42
+
43
+ ### brotli.compress(buffer, isText = false)
44
+
45
+ Compresses the given buffer. Pass optional parameters as the second argument.
46
+
47
+ ```javascript
48
+ // encode a buffer of binary data
49
+ brotli.compress(fs.readFileSync('myfile.bin'));
50
+
51
+ // encode some data with options (default options shown)
52
+ brotli.compress(fs.readFileSync('myfile.bin'), {
53
+ mode: 0, // 0 = generic, 1 = text, 2 = font (WOFF2)
54
+ quality: 11, // 0 - 11
55
+ lgwin: 22 // window size
56
+ });
57
+ ```
58
+
59
+ ## License
60
+
61
+ MIT
@@ -0,0 +1,18 @@
1
+ Copyright © 2011-2015 Paul Vorbach <paul@vorba.ch>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the “Software”), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, OUT OF OR IN CONNECTION WITH THE
18
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,83 @@
1
+ # dfa
2
+
3
+ Compiles a regular expression like syntax to fast deterministic finite automata.
4
+ Useful for pattern matching against non-string sequences.
5
+
6
+ ## Example
7
+
8
+ This example matches [Hangul](https://en.wikipedia.org/wiki/Hangul) syllables. The symbols defined in the machine are Unicode character categories which could be mapped from code points.
9
+
10
+ Machine definition:
11
+
12
+ ```coffeescript
13
+ # define symbols
14
+ X = 0; # Other character
15
+ L = 1; # Leading consonant
16
+ V = 2; # Medial vowel
17
+ T = 3; # Trailing consonant
18
+ LV = 4; # Composed <LV> syllable
19
+ LVT = 5; # Composed <LVT> syllable
20
+ M = 6; # Tone mark
21
+
22
+ # define variables
23
+ decomposed = L V T?;
24
+ partial = LV T?;
25
+ composed = LVT;
26
+
27
+ # define main state machine pattern
28
+ main = (decomposed | partial | composed) M?;
29
+ ```
30
+
31
+ Visualized, the machine looks like this (double circles are accepting states):
32
+
33
+ ![dfa](https://cloud.githubusercontent.com/assets/19409/19143719/8fbc6a12-8b5a-11e6-868d-99621644d094.png)
34
+
35
+ Compiling and using the machine:
36
+
37
+ ```javascript
38
+ import compile from 'dfa/compile';
39
+ import fs from 'fs';
40
+
41
+ let stateMachine = compile(fs.readFileSync('hangul.machine', 'utf8'));
42
+
43
+ // find matches
44
+ for (let [startIndex, endIndex] of stateMachine.match([0, 1, 2, 3, 0, 4, 6]) {
45
+ console.log('match:', startIndex, endIndex);
46
+ }
47
+ ```
48
+
49
+ Output:
50
+ ```
51
+ match: 1 3
52
+ match: 5 6
53
+ ```
54
+
55
+ ## Syntax
56
+
57
+ A state machine file contains a list of assignment statements. Comments are also allowed
58
+ and are started with the `#` character. Each statement is an assignment of a variable name
59
+ to a value or expression. Assigning a variable to a number produces a symbol, which is
60
+ added to the state machine's alphabet. Assigning a variable to an expression allows
61
+ for substitutions into later expressions. The special `main` variable should always be
62
+ assigned to at the end of the file, and is the final expression that will be compiled.
63
+
64
+ A subset of common regular expression syntax is supported. A list of operators and their
65
+ precedence is below. Operators with the same precedence are evaluated left to right.
66
+
67
+ | Precedence | Syntax | Type | Meaning |
68
+ | ---------- | ---------- | --------------| ------------------------------------------ |
69
+ | 1 | `a \| b` | Alternation | Matches either `a` or `b` |
70
+ | 2 | `a b` | Concatenation | Matches `a` followed by `b` |
71
+ | 3 | `a*` | Repetition | Matches zero or more occurrences of `a` |
72
+ | 3 | `a+` | Repetition | Matches one ore more occurrences of `a` |
73
+ | 3 | `a?` | Optional | Matches zero or one occurrence of `a` |
74
+ | 3 | `a{n}` | Repetition | Matches exactly n occurrences of `a` |
75
+ | 3 | `a{n,}` | Repetition | Matches n or more occurrences of `a` |
76
+ | 3 | `a{,n}` | Repetition | Matches up to n occurrences of `a` |
77
+ | 3 | `a{n,m}` | Repetition | Matches n to m occurrences of `a` |
78
+ | 4 | `t:<expr>` | Tag | Tags the following expression with tag `t` |
79
+ | 5 | `(<expr>)` | Grouping | Groups an expression |
80
+
81
+ ## License
82
+
83
+ MIT
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Evgeny Poberezkin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,266 @@
1
+ # fontkit
2
+
3
+ Fontkit is an advanced font engine for Node and the browser, used by [PDFKit](https://github.com/devongovett/pdfkit). It supports many font formats, advanced glyph substitution and layout features, glyph path extraction, color emoji glyphs, font subsetting, and more.
4
+
5
+ ## Features
6
+
7
+ * Supports TrueType (.ttf), OpenType (.otf), WOFF, WOFF2, TrueType Collection (.ttc), and Datafork TrueType (.dfont) font files
8
+ * Supports mapping characters to glyphs, including support for ligatures and other advanced substitutions (see below)
9
+ * Supports reading glyph metrics and laying out glyphs, including support for kerning and other advanced layout features (see below)
10
+ * Advanced OpenType features including glyph substitution (GSUB) and positioning (GPOS)
11
+ * Apple Advanced Typography (AAT) glyph substitution features (morx table)
12
+ * Support for getting glyph vector paths and converting them to SVG paths, or rendering them to a graphics context
13
+ * Supports TrueType (glyf) and PostScript (CFF) outlines
14
+ * Support for color glyphs (e.g. emoji), including Apple’s SBIX table, and Microsoft’s COLR table
15
+ * Support for AAT variation glyphs, allowing for nearly infinite design control over weight, width, and other axes.
16
+ * Font subsetting support - create a new font including only the specified glyphs
17
+
18
+ ## Installation
19
+
20
+ npm install fontkit
21
+
22
+ ## Example
23
+
24
+ ```javascript
25
+ var fontkit = require('fontkit');
26
+
27
+ // open a font synchronously
28
+ var font = fontkit.openSync('font.ttf');
29
+
30
+ // layout a string, using default shaping features.
31
+ // returns a GlyphRun, describing glyphs and positions.
32
+ var run = font.layout('hello world!');
33
+
34
+ // get an SVG path for a glyph
35
+ var svg = run.glyphs[0].path.toSVG();
36
+
37
+ // create a font subset
38
+ var subset = font.createSubset();
39
+ run.glyphs.forEach(function(glyph) {
40
+ subset.includeGlyph(glyph);
41
+ });
42
+
43
+ let buffer = subset.encode();
44
+ ```
45
+
46
+ ## API
47
+
48
+ ### `fontkit.open(filename, postscriptName = null)`
49
+
50
+ Opens a font file asynchronously, and returns a `Promise` with a font object. For collection fonts (such as TrueType collection files), you can pass a `postscriptName` to get that font out of the collection instead of a collection object.
51
+
52
+ ### `fontkit.openSync(filename, postscriptName = null)`
53
+
54
+ Opens a font file synchronously, and returns a font object. For collection fonts (such as TrueType collection files), you can pass a `postscriptName` to get that font out of the collection instead of a collection object.
55
+
56
+ ### `fontkit.create(buffer, postscriptName = null)`
57
+
58
+ Returns a font object for the given buffer. For collection fonts (such as TrueType collection files), you can pass a `postscriptName` to get that font out of the collection instead of a collection object.
59
+
60
+ ## Font objects
61
+
62
+ There are several different types of font objects that are returned by fontkit depending on the font format. They all inherit from the `TTFFont` class and have the same public API, described below.
63
+
64
+ ### Metadata properties
65
+
66
+ The following properties are strings (or null if the font does not contain strings for them) describing the font, as specified by the font creator.
67
+
68
+ * `postscriptName`
69
+ * `fullName`
70
+ * `familyName`
71
+ * `subfamilyName`
72
+ * `copyright`
73
+ * `version`
74
+
75
+ ### Metrics
76
+
77
+ The following properties describe the general metrics of the font. See [here](http://www.freetype.org/freetype2/docs/glyphs/glyphs-3.html) for a good overview of how all of these properties relate to one another.
78
+
79
+ * `unitsPerEm` - the size of the font’s internal coordinate grid
80
+ * `ascent` - the font’s [ascender](http://en.wikipedia.org/wiki/Ascender_(typography))
81
+ * `descent` - the font’s [descender](http://en.wikipedia.org/wiki/Descender)
82
+ * `lineGap` - the amount of space that should be included between lines
83
+ * `underlinePosition` - the offset from the normal underline position that should be used
84
+ * `underlineThickness` - the weight of the underline that should be used
85
+ * `italicAngle` - if this is an italic font, the angle the cursor should be drawn at to match the font design
86
+ * `capHeight` - the height of capital letters above the baseline. See [here](http://en.wikipedia.org/wiki/Cap_height) for more details.
87
+ * `xHeight`- the height of lower case letters. See [here](http://en.wikipedia.org/wiki/X-height) for more details.
88
+ * `bbox` - the font’s bounding box, i.e. the box that encloses all glyphs in the font
89
+
90
+ ### Other properties
91
+
92
+ * `numGlyphs` - the number of glyphs in the font
93
+ * `characterSet` - an array of all of the unicode code points supported by the font
94
+ * `availableFeatures` - an array of all [OpenType feature tags](https://www.microsoft.com/typography/otspec/featuretags.htm) (or mapped AAT tags) supported by the font (see below for a description of this)
95
+
96
+ ### Character to glyph mapping
97
+
98
+ Fontkit includes several methods for character to glyph mapping, including support for advanced OpenType and AAT substitutions.
99
+
100
+ #### `font.glyphForCodePoint(codePoint)`
101
+
102
+ Maps a single unicode code point (number) to a Glyph object. Does not perform any advanced substitutions (there is no context to do so).
103
+
104
+ #### `font.hasGlyphForCodePoint(codePoint)`
105
+
106
+ Returns whether there is glyph in the font for the given unicode code point.
107
+
108
+ #### `font.glyphsForString(string)`
109
+
110
+ This method returns an array of Glyph objects for the given string. This is only a one-to-one mapping from characters
111
+ to glyphs. For most uses, you should use `font.layout` (described below), which provides a much more advanced mapping
112
+ supporting AAT and OpenType shaping.
113
+
114
+ ### Glyph metrics and layout
115
+
116
+ Fontkit includes several methods for accessing glyph metrics and performing layout, including support for kerning and other advanced OpenType positioning adjustments.
117
+
118
+ #### `font.widthOfGlyph(glyph_id)`
119
+
120
+ Returns the advance width (described above) for a single glyph id.
121
+
122
+ #### `font.layout(string, features = [] | {})`
123
+
124
+ This method returns a `GlyphRun` object, which includes an array of `Glyph`s and `GlyphPosition`s for the given string.
125
+ `Glyph` objects are described below. `GlyphPosition` objects include 4 properties: `xAdvance`, `yAdvance`, `xOffset`,
126
+ and `yOffset`.
127
+
128
+ The `features` parameter is either an array of [OpenType feature tags](https://www.microsoft.com/typography/otspec/featuretags.htm) to be applied
129
+ in addition to the default set, or an object mapping OpenType features to a boolean enabling or disabling each. If this is an AAT font, the OpenType feature tags are mapped to AAT features.
130
+
131
+ ### Variation fonts
132
+
133
+ Fontkit has support for AAT variation fonts, where glyphs can adjust their shape according to user defined settings along
134
+ various axes including weight, width, and slant. Font designers specify the minimum, default, and maximum values for each
135
+ axis they support, and allow the user fine grained control over the rendered text.
136
+
137
+ #### `font.variationAxes`
138
+
139
+ Returns an object describing the available variation axes. Keys are 4 letter axis tags, and values include `name`,
140
+ `min`, `default`, and `max` properties for the axis.
141
+
142
+ #### `font.namedVariations`
143
+
144
+ The font designer may have picked out some variations that they think look particularly good, for example a light, regular,
145
+ and bold weight which would traditionally be separate fonts. This property returns an object describing these named variation
146
+ instances that the designer has specified. Keys are variation names, and values are objects with axis settings.
147
+
148
+ #### `font.getVariation(variation)`
149
+
150
+ Returns a new font object representing this variation, from which you can get glyphs and perform layout as normal.
151
+ The `variation` parameter can either be a variation settings object or a string variation name. Variation settings objects
152
+ have axis names as keys, and numbers as values (should be in the range specified by `font.variationAxes`).
153
+
154
+ ### Other methods
155
+
156
+ #### `font.getGlyph(glyph_id, codePoints = [])`
157
+
158
+ Returns a glyph object for the given glyph id. You can pass the array of code points this glyph represents for your use later, and it will be stored in the glyph object.
159
+
160
+ #### `font.createSubset()`
161
+
162
+ Returns a Subset object for this font, described below.
163
+
164
+ ## Font Collection objects
165
+
166
+ For font collection files that contain multiple fonts in a single file, such as TrueType Collection (.ttc) and Datafork TrueType (.dfont) files, a font collection object can be returned by Fontkit.
167
+
168
+ ### `collection.getFont(postscriptName)`
169
+
170
+ Gets a font from the collection by its postscript name. Returns a Font object, described above.
171
+
172
+ ### `collection.fonts`
173
+
174
+ This property is a lazily-loaded array of all of the fonts in the collection.
175
+
176
+ ## Glyph objects
177
+
178
+ Glyph objects represent a glyph in the font. They have various properties for accessing metrics and the actual vector path the glyph represents, and methods for rendering the glyph to a graphics context.
179
+
180
+ You do not create glyph objects directly. They are created by various methods on the font object, described above. There are several subclasses of the base `Glyph` class internally that may be returned depending on the font format, but they all include the following API.
181
+
182
+ ### Properties
183
+
184
+ * `id` - the glyph id in the font
185
+ * `name` - the glyph name in the font
186
+ * `codePoints` - an array of unicode code points that are represented by this glyph. There can be multiple code points in the case of ligatures and other glyphs that represent multiple visual characters.
187
+ * `path` - a vector Path object representing the glyph
188
+ * `bbox` - the glyph’s bounding box, i.e. the rectangle that encloses the glyph outline as tightly as possible.
189
+ * `cbox` - the glyph’s control box. This is often the same as the bounding box, but is faster to compute. Because of the way bezier curves are defined, some of the control points can be outside of the bounding box. Where `bbox` takes this into account, `cbox` does not. Thus, `cbox` is less accurate, but faster to compute. See [here](http://www.freetype.org/freetype2/docs/glyphs/glyphs-6.html#section-2) for a more detailed description.
190
+ * `advanceWidth` - the glyph’s advance width.
191
+
192
+ ### `glyph.render(ctx, size)`
193
+
194
+ Renders the glyph to the given graphics context, at the specified font size.
195
+
196
+ ### Color glyphs (e.g. emoji)
197
+
198
+ Fontkit has support for several different color emoji font formats. Currently, these include Apple’s SBIX table (as used by the “Apple Color Emoji” font), and Microsoft’s COLR table (supported by Windows 8.1). [Here](http://blog.symbolset.com/multicolor-fonts) is an overview of the various color font formats out there.
199
+
200
+ #### `glyph.getImageForSize(size)`
201
+
202
+ For SBIX glyphs, which are bitmap based, this returns an object containing some properties about the image, along with the image data itself (usually PNG).
203
+
204
+ #### `glyph.layers`
205
+
206
+ For COLR glyphs, which are vector based, this returns an array of objects representing the glyphs and colors for each layer in render order.
207
+
208
+ ## Path objects
209
+
210
+ Path objects are returned by glyphs and represent the actual vector outlines for each glyph in the font. Paths can be converted to SVG path data strings, or to functions that can be applied to render the path to a graphics context.
211
+
212
+ ### `path.moveTo(x, y)`
213
+
214
+ Moves the virtual pen to the given x, y coordinates.
215
+
216
+ ### `path.lineTo(x, y)`
217
+
218
+ Adds a line to the path from the current point to the given x, y coordinates.
219
+
220
+ ### `path.quadraticCurveTo(cpx, cpy, x, y)`
221
+
222
+ Adds a quadratic curve to the path from the current point to the given x, y coordinates using cpx, cpy as a control point.
223
+
224
+ ### `path.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y)`
225
+
226
+ Adds a bezier curve to the path from the current point to the given x, y coordinates using cp1x, cp1y and cp2x, cp2y as control points.
227
+
228
+ ### `path.closePath()`
229
+
230
+ Closes the current sub-path by drawing a straight line back to the starting point.
231
+
232
+ ### `path.toFunction()`
233
+
234
+ Compiles the path to a JavaScript function that can be applied with a graphics context in order to render the path.
235
+
236
+ ### `path.toSVG()`
237
+
238
+ Converts the path to an SVG path data string.
239
+
240
+ ### `path.bbox`
241
+
242
+ This property represents the path’s bounding box, i.e. the smallest rectangle that contains the entire path shape. This is the exact bounding box, taking into account control points that may be outside the visible shape.
243
+
244
+ ### `path.cbox`
245
+
246
+ This property represents the path’s control box. It is like the bounding box, but it includes all points of the path, including control points of bezier segments. It is much faster to compute than the real bounding box, but less accurate if there are control points outside of the visible shape.
247
+
248
+ ## Subsets
249
+
250
+ Fontkit can perform font subsetting, i.e. the process of creating a new font from an existing font where only the specified glyphs are included. This is useful to reduce the size of large fonts, such as in PDF generation or for web use.
251
+
252
+ Currently, subsets produce minimal fonts designed for PDF embedding that may not work as standalone files. They have no cmap tables and other essential tables for standalone use. This limitation will be removed in the future.
253
+
254
+ You create a Subset object by calling `font.createSubset()`, described above. The API on Subset objects is as follows.
255
+
256
+ ### `subset.includeGlyph(glyph)`
257
+
258
+ Includes the given glyph object or glyph ID in the subset.
259
+
260
+ ### `subset.encode()`
261
+
262
+ Returns a `Uint8Array` containing the encoded font file.
263
+
264
+ ## License
265
+
266
+ MIT