Skip to content

Commit de9d26d

Browse files
committed
Auto-generated commit
1 parent becfa6e commit de9d26d

File tree

3 files changed

+44
-10
lines changed

3 files changed

+44
-10
lines changed

.github/.keepalive

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2022-02-02T16:58:15.603Z
1+
2022-02-04T23:39:51.832Z

.github/workflows/bundle.yml

+30-9
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ jobs:
6969
7070
# Rewrite all `require()`s to use jsDelivr links:
7171
find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// {
72-
s/(var|let|const)\s+([a-z0-9]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i
72+
s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i
7373
s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/
7474
s/';/@deno\/mod.js';/
7575
}"
7676
7777
# Remove `installation`, `cli`, and `c` sections:
7878
find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"installation\">[^<]+<\/section>//g;"
79-
find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"cli\">[\s\S]+<\!\-\- \/.cli \-\->//g"
80-
find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"c\">[\s\S]+<\!\-\- \/.c \-\->//g"
79+
find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"cli\">[\s\S]+<\!\-\- \/.cli \-\->//g"
80+
find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"c\">[\s\S]+<\!\-\- \/.c \-\->//g"
8181
8282
- name: Publish to deno branch
8383
uses: peaceiris/actions-gh-pages@v3
@@ -107,18 +107,39 @@ jobs:
107107
run: |
108108
npm install || npm install || npm install
109109
timeout-minutes: 15
110+
- name: Extract Alias
111+
id: extract-alias
112+
run: |
113+
alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/')
114+
echo "::set-output name=alias::${alias}"
110115
- name: Create Universal Module Definition (UMD) bundle
111116
id: umd-bundle
112117
uses: stdlib-js/bundle-action@main
113118
with:
114119
target: 'umd'
120+
alias: ${{ steps.extract-alias.outputs.alias }}
115121
- name: Rewrite file contents
116122
run: |
117123
124+
# Replace links to other packages with links to the umd branch:
125+
find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/";
126+
118127
# Remove `installation`, `cli`, and `c` sections:
119128
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"installation\">[^<]+<\/section>//g;"
120-
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"cli\">[\s\S]+<\!\-\- \/.cli \-\->//g"
121-
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"c\">[\s\S]+<\!\-\- \/.c \-\->//g"
129+
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"cli\">[\s\S]+<\!\-\- \/.cli \-\->//g"
130+
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"c\">[\s\S]+<\!\-\- \/.c \-\->//g"
131+
132+
# Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag:
133+
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/bundle.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n<script type=\"text\/javascript\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/bundle.js\"><\/script>\n\`\`\`\n\nIf no recognized module system is present, access bundle contents via the global scope:\n\n\`\`\`html\n<script type=\"text\/javascript\">\n window.\2;\n<\/script>\n\`\`\`/"
134+
135+
# Rewrite examples section to be a HTML file:
136+
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\#\# Examples([\s\S]*)\`\`\`javascript([\s\S]+?)\`\`\`/\#\# Examples\1\`\`\`html\n<\!DOCTYPE html>\n<html lang=\"en\">\n<body>\n<script type=\"text\/javascript\">\2\n<\/script>\n<\/body>\n<\/html>\n\`\`\`/"
137+
138+
# Rewrite all `require()`s in the examples section as `script` tags loading the respective UMD bundle:
139+
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "1 while s/<script type=\"text\/javascript\">\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);?/<script type=\"text\/javascript\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/bundle.js\"><\/script>\n<script type=\"text\/javascript\">/g"
140+
141+
# Wrap contents of `<script type="text/javascript">` tag contents in an IIFE:
142+
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<script type=\"text\/javascript\">([\s\S]+?)<\/script>/<script type=\"text\/javascript\">\n\(function \(\) {\1}\)\(\)\n<\/script>/g"
122143
123144
- name: Publish to umd branch
124145
uses: peaceiris/actions-gh-pages@v3
@@ -175,18 +196,18 @@ jobs:
175196
176197
# Rewrite all `require()`s to use jsDelivr links:
177198
find ./esm -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// {
178-
s/(var|let|const)\s+([a-z0-9]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i
199+
s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i
179200
s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/
180201
s/';/@esm\/index.mjs';/
181202
}"
182203
183204
# Remove `installation`, `cli`, and `c` sections:
184205
find ./esm -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"installation\">[^<]+<\/section>//g;"
185-
find ./esm -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"cli\">[\s\S]+<\!\-\- \/.cli \-\->//g"
186-
find ./esm -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"c\">[\s\S]+<\!\-\- \/.c \-\->//g"
206+
find ./esm -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"cli\">[\s\S]+<\!\-\- \/.cli \-\->//g"
207+
find ./esm -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"c\">[\s\S]+<\!\-\- \/.c \-\->//g"
187208
188209
# Rewrite examples section to be a HTML file:
189-
find ./esm -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\#\# Examples([\s\S]*)\`\`\`javascript([\s\S]+?)\`\`\`/\#\# Examples\1\`\`\`html\n<\!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<script type=\"module\">\n\2\n<\/script>\n<\/head>\n<\/html>\n\`\`\`/g"
210+
find ./esm -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\#\# Examples([\s\S]*)\`\`\`javascript([\s\S]+?)\`\`\`/\#\# Examples\1\`\`\`html\n<\!DOCTYPE html>\n<html lang=\"en\">\n<body>\n<script type=\"module\">\n\2\n<\/script>\n<\/body>\n<\/html>\n\`\`\`/g"
190211
191212
- name: Publish to esm branch
192213
uses: peaceiris/actions-gh-pages@v3

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ limitations under the License.
4242
npm install @stdlib/iter-to-array-view
4343
```
4444

45+
Alternatively,
46+
47+
- To load the package in a website via a `script` tag without installation and bundlers, use the [ES Module][es-module] available on the [`esm` branch][esm-url].
48+
- If you are using Deno, visit the [`deno` branch][deno-url].
49+
- For use in Observable, or in browser/node environments, use the [Universal Module Definition (UMD)][umd] build available on the [`umd` branch][umd-url].
50+
4551
</section>
4652

4753
<section class="usage">
@@ -298,6 +304,13 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
298304
299305
-->
300306

307+
[umd]: https://github.com/umdjs/umd
308+
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
309+
310+
[deno-url]: https://github.com/stdlib-js/iter-to-array-view/tree/deno
311+
[umd-url]: https://github.com/stdlib-js/iter-to-array-view/tree/umd
312+
[esm-url]: https://github.com/stdlib-js/iter-to-array-view/tree/esm
313+
301314
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
302315
[chat-url]: https://gitter.im/stdlib-js/stdlib/
303316

0 commit comments

Comments
 (0)