diff options
| author | qsm-odoo <qsm@odoo.com> | 2016-09-13 12:31:47 +0200 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2016-09-13 14:18:31 +0200 |
| commit | d83f7587aae3fd2fcd4b6c4622ee7bcca9e80abe (patch) | |
| tree | a9114bd3014f61583609a75c1b5d5af85397a2a6 /addons/web/static/lib/pdfjs/external | |
| parent | 837be69785ee24b8a7b0230ff6bc7e70cba5f5c5 (diff) | |
[MOV] web, website(_slides): move PDFjs lib to web
website_sign is now a backend-only module in enterprise, so it should
not use a website library (even in a static way).
Diffstat (limited to 'addons/web/static/lib/pdfjs/external')
185 files changed, 5687 insertions, 0 deletions
diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/78-EUC-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/78-EUC-H.bcmap Binary files differnew file mode 100644 index 00000000000..2655fc70ae7 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/78-EUC-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/78-EUC-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/78-EUC-V.bcmap Binary files differnew file mode 100644 index 00000000000..f1ed8538287 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/78-EUC-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/78-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/78-H.bcmap Binary files differnew file mode 100644 index 00000000000..39e89d3339c --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/78-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/78-RKSJ-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/78-RKSJ-H.bcmap Binary files differnew file mode 100644 index 00000000000..e4167cb51f6 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/78-RKSJ-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/78-RKSJ-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/78-RKSJ-V.bcmap Binary files differnew file mode 100644 index 00000000000..50b1646e94b --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/78-RKSJ-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/78-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/78-V.bcmap Binary files differnew file mode 100644 index 00000000000..d7af99b5e2a --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/78-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/78ms-RKSJ-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/78ms-RKSJ-H.bcmap Binary files differnew file mode 100644 index 00000000000..37077d01e26 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/78ms-RKSJ-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/78ms-RKSJ-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/78ms-RKSJ-V.bcmap Binary files differnew file mode 100644 index 00000000000..acf23231aea --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/78ms-RKSJ-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/83pv-RKSJ-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/83pv-RKSJ-H.bcmap Binary files differnew file mode 100644 index 00000000000..2359bc529d1 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/83pv-RKSJ-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/90ms-RKSJ-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/90ms-RKSJ-H.bcmap Binary files differnew file mode 100644 index 00000000000..af8293829c9 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/90ms-RKSJ-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/90ms-RKSJ-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/90ms-RKSJ-V.bcmap Binary files differnew file mode 100644 index 00000000000..780549de19d --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/90ms-RKSJ-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/90msp-RKSJ-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/90msp-RKSJ-H.bcmap Binary files differnew file mode 100644 index 00000000000..bfd3119c62d --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/90msp-RKSJ-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/90msp-RKSJ-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/90msp-RKSJ-V.bcmap Binary files differnew file mode 100644 index 00000000000..25ef14ab4af --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/90msp-RKSJ-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/90pv-RKSJ-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/90pv-RKSJ-H.bcmap Binary files differnew file mode 100644 index 00000000000..02f713bb838 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/90pv-RKSJ-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/90pv-RKSJ-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/90pv-RKSJ-V.bcmap Binary files differnew file mode 100644 index 00000000000..d08e0cc5d98 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/90pv-RKSJ-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Add-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Add-H.bcmap Binary files differnew file mode 100644 index 00000000000..59442acafb6 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Add-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Add-RKSJ-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Add-RKSJ-H.bcmap Binary files differnew file mode 100644 index 00000000000..a3065e441a0 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Add-RKSJ-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Add-RKSJ-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Add-RKSJ-V.bcmap Binary files differnew file mode 100644 index 00000000000..040014cfc08 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Add-RKSJ-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Add-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Add-V.bcmap Binary files differnew file mode 100644 index 00000000000..2f816d320f0 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Add-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-0.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-0.bcmap Binary files differnew file mode 100644 index 00000000000..88ec04af49d --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-0.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-1.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-1.bcmap Binary files differnew file mode 100644 index 00000000000..03a501477c9 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-1.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-2.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-2.bcmap Binary files differnew file mode 100644 index 00000000000..2aa95141f9f --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-2.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-3.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-3.bcmap Binary files differnew file mode 100644 index 00000000000..86d8b8c79cf --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-3.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-4.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-4.bcmap Binary files differnew file mode 100644 index 00000000000..f50fc6c14e6 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-4.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-5.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-5.bcmap Binary files differnew file mode 100644 index 00000000000..6caf4a83146 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-5.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-6.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-6.bcmap Binary files differnew file mode 100644 index 00000000000..b77fb0705c2 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-6.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-UCS2.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-UCS2.bcmap Binary files differnew file mode 100644 index 00000000000..69d79a2c2c2 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-CNS1-UCS2.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-0.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-0.bcmap Binary files differnew file mode 100644 index 00000000000..36101083fa8 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-0.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-1.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-1.bcmap Binary files differnew file mode 100644 index 00000000000..707bb1065c7 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-1.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-2.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-2.bcmap Binary files differnew file mode 100644 index 00000000000..f7648cc3ff0 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-2.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-3.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-3.bcmap Binary files differnew file mode 100644 index 00000000000..852145890ed --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-3.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-4.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-4.bcmap Binary files differnew file mode 100644 index 00000000000..e40c63ab1e5 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-4.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-5.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-5.bcmap Binary files differnew file mode 100644 index 00000000000..d7623b50023 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-5.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-UCS2.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-UCS2.bcmap Binary files differnew file mode 100644 index 00000000000..7586525936c --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-GB1-UCS2.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-0.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-0.bcmap Binary files differnew file mode 100644 index 00000000000..f0e94ec1967 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-0.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-1.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-1.bcmap Binary files differnew file mode 100644 index 00000000000..dad42c5ad7d --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-1.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-2.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-2.bcmap Binary files differnew file mode 100644 index 00000000000..090819a0645 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-2.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-3.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-3.bcmap Binary files differnew file mode 100644 index 00000000000..087dfc15586 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-3.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-4.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-4.bcmap Binary files differnew file mode 100644 index 00000000000..46aa9bffe57 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-4.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-5.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-5.bcmap Binary files differnew file mode 100644 index 00000000000..5b4b65cc629 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-5.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-6.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-6.bcmap Binary files differnew file mode 100644 index 00000000000..e77d699ab6a --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-6.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-UCS2.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-UCS2.bcmap Binary files differnew file mode 100644 index 00000000000..128a1410775 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Japan1-UCS2.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Korea1-0.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Korea1-0.bcmap Binary files differnew file mode 100644 index 00000000000..cef1a998519 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Korea1-0.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Korea1-1.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Korea1-1.bcmap Binary files differnew file mode 100644 index 00000000000..11ffa36df84 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Korea1-1.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Korea1-2.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Korea1-2.bcmap Binary files differnew file mode 100644 index 00000000000..3172308c79d --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Korea1-2.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Korea1-UCS2.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Korea1-UCS2.bcmap Binary files differnew file mode 100644 index 00000000000..f3371c0cbd1 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Adobe-Korea1-UCS2.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/B5-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/B5-H.bcmap Binary files differnew file mode 100644 index 00000000000..beb4d228104 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/B5-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/B5-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/B5-V.bcmap Binary files differnew file mode 100644 index 00000000000..2d4f87d5035 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/B5-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/B5pc-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/B5pc-H.bcmap Binary files differnew file mode 100644 index 00000000000..ce0013167f8 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/B5pc-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/B5pc-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/B5pc-V.bcmap Binary files differnew file mode 100644 index 00000000000..73b99ff2fbc --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/B5pc-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/CNS-EUC-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/CNS-EUC-H.bcmap Binary files differnew file mode 100644 index 00000000000..61d1d0cb001 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/CNS-EUC-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/CNS-EUC-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/CNS-EUC-V.bcmap Binary files differnew file mode 100644 index 00000000000..1a393a51e07 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/CNS-EUC-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/CNS1-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/CNS1-H.bcmap Binary files differnew file mode 100644 index 00000000000..f738e218ae2 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/CNS1-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/CNS1-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/CNS1-V.bcmap Binary files differnew file mode 100644 index 00000000000..9c3169f0d9a --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/CNS1-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/CNS2-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/CNS2-H.bcmap Binary files differnew file mode 100644 index 00000000000..c89b3527fe5 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/CNS2-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/CNS2-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/CNS2-V.bcmap new file mode 100644 index 00000000000..7588cec83e2 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/CNS2-V.bcmap @@ -0,0 +1,3 @@ +àRCopyright 1990-2009 Adobe Systems Incorporated. +All rights reserved. +See ./LICENSEáCNS2-H
\ No newline at end of file diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/ETHK-B5-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/ETHK-B5-H.bcmap Binary files differnew file mode 100644 index 00000000000..cb29415de4f --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/ETHK-B5-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/ETHK-B5-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/ETHK-B5-V.bcmap Binary files differnew file mode 100644 index 00000000000..f09aec6318d --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/ETHK-B5-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/ETen-B5-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/ETen-B5-H.bcmap Binary files differnew file mode 100644 index 00000000000..c2d77462d29 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/ETen-B5-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/ETen-B5-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/ETen-B5-V.bcmap Binary files differnew file mode 100644 index 00000000000..89bff159ec6 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/ETen-B5-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/ETenms-B5-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/ETenms-B5-H.bcmap new file mode 100644 index 00000000000..a7d69db5e32 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/ETenms-B5-H.bcmap @@ -0,0 +1,3 @@ +àRCopyright 1990-2009 Adobe Systems Incorporated. +All rights reserved. +See ./LICENSEá ETen-B5-H` ^
\ No newline at end of file diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/ETenms-B5-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/ETenms-B5-V.bcmap Binary files differnew file mode 100644 index 00000000000..adc5d618d69 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/ETenms-B5-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/EUC-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/EUC-H.bcmap Binary files differnew file mode 100644 index 00000000000..e92ea5b3b99 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/EUC-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/EUC-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/EUC-V.bcmap Binary files differnew file mode 100644 index 00000000000..7a7c183228d --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/EUC-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Ext-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Ext-H.bcmap Binary files differnew file mode 100644 index 00000000000..3b5cde44dba --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Ext-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Ext-RKSJ-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Ext-RKSJ-H.bcmap Binary files differnew file mode 100644 index 00000000000..ea4d2d97b8b --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Ext-RKSJ-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Ext-RKSJ-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Ext-RKSJ-V.bcmap Binary files differnew file mode 100644 index 00000000000..3457c277091 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Ext-RKSJ-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Ext-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Ext-V.bcmap Binary files differnew file mode 100644 index 00000000000..4999ca40412 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Ext-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GB-EUC-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GB-EUC-H.bcmap Binary files differnew file mode 100644 index 00000000000..e39908b9844 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GB-EUC-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GB-EUC-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GB-EUC-V.bcmap Binary files differnew file mode 100644 index 00000000000..d5be5446aa4 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GB-EUC-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GB-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GB-H.bcmap new file mode 100644 index 00000000000..39189c54e36 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GB-H.bcmap @@ -0,0 +1,4 @@ +àRCopyright 1990-2009 Adobe Systems Incorporated. +All rights reserved. +See ./LICENSE!!�º]aX!!]`�21�> �p�z�$]‚�"R‚d�-Uƒ7�*„
4„%�+ „Z „{�/…%…<�9K…b�1]†.�"‡‰`]‡,�"]ˆ +�"]ˆh�"]‰F�"]Š$�"]‹�"]‹`�"]Œ>�"]��"]�z�"]ŽX�"]�6�"]��"]�r�"]‘P�"]’.�"]“�"]“j�"]”H�"]•&�"]–�"]–b�"]—@�"]˜�"]˜|�"]™Z�"]š8�"]›�"]›t�"]œR�"]�0�"]ž�"]žl�"]ŸJ�"] (�"]¡�"]¡d�"]¢B�"]£ �"X£~�']¤W�"]¥5�"]¦�"]¦q�"]§O�"]¨-�"]©�"]©i�"]ªG�"]«%�"]¬�"]¬a�"]?�"]®�"]®{�"]¯Y�"]°7�"]±�"]±s�"]²Q�"]³/�"]´
�"]´k�"]µI�"]¶'�"]·�"]·c�"]¸A�"]¹�"]¹}�"]º[�"]»9
\ No newline at end of file diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GB-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GB-V.bcmap Binary files differnew file mode 100644 index 00000000000..310834512ff --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GB-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GBK-EUC-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GBK-EUC-H.bcmap Binary files differnew file mode 100644 index 00000000000..05fff7e8254 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GBK-EUC-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GBK-EUC-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GBK-EUC-V.bcmap Binary files differnew file mode 100644 index 00000000000..0cdf6bed6d4 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GBK-EUC-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GBK2K-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GBK2K-H.bcmap Binary files differnew file mode 100644 index 00000000000..46f6ba5967c --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GBK2K-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GBK2K-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GBK2K-V.bcmap Binary files differnew file mode 100644 index 00000000000..d9a9479843e --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GBK2K-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GBKp-EUC-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GBKp-EUC-H.bcmap Binary files differnew file mode 100644 index 00000000000..5cb0af687ee --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GBKp-EUC-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GBKp-EUC-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GBKp-EUC-V.bcmap Binary files differnew file mode 100644 index 00000000000..bca93b8efbb --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GBKp-EUC-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GBT-EUC-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GBT-EUC-H.bcmap Binary files differnew file mode 100644 index 00000000000..4b4e2d32294 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GBT-EUC-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GBT-EUC-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GBT-EUC-V.bcmap Binary files differnew file mode 100644 index 00000000000..38f706699f3 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GBT-EUC-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GBT-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GBT-H.bcmap Binary files differnew file mode 100644 index 00000000000..8437ac33771 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GBT-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GBT-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GBT-V.bcmap Binary files differnew file mode 100644 index 00000000000..697ab4a8e75 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GBT-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GBTpc-EUC-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GBTpc-EUC-H.bcmap Binary files differnew file mode 100644 index 00000000000..f6e50e89363 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GBTpc-EUC-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GBTpc-EUC-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GBTpc-EUC-V.bcmap Binary files differnew file mode 100644 index 00000000000..6c0d71a2d04 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GBTpc-EUC-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GBpc-EUC-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GBpc-EUC-H.bcmap Binary files differnew file mode 100644 index 00000000000..c9edf67cf6d --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GBpc-EUC-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/GBpc-EUC-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/GBpc-EUC-V.bcmap Binary files differnew file mode 100644 index 00000000000..31450c97f64 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/GBpc-EUC-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/H.bcmap Binary files differnew file mode 100644 index 00000000000..7b24ea4629d --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/HKdla-B5-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/HKdla-B5-H.bcmap Binary files differnew file mode 100644 index 00000000000..7d30c050052 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/HKdla-B5-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/HKdla-B5-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/HKdla-B5-V.bcmap Binary files differnew file mode 100644 index 00000000000..78946940d68 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/HKdla-B5-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/HKdlb-B5-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/HKdlb-B5-H.bcmap Binary files differnew file mode 100644 index 00000000000..d829a231015 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/HKdlb-B5-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/HKdlb-B5-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/HKdlb-B5-V.bcmap Binary files differnew file mode 100644 index 00000000000..2b572b50a47 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/HKdlb-B5-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/HKgccs-B5-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/HKgccs-B5-H.bcmap Binary files differnew file mode 100644 index 00000000000..971a4f23f79 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/HKgccs-B5-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/HKgccs-B5-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/HKgccs-B5-V.bcmap Binary files differnew file mode 100644 index 00000000000..d353ca256b5 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/HKgccs-B5-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/HKm314-B5-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/HKm314-B5-H.bcmap Binary files differnew file mode 100644 index 00000000000..576dc01112b --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/HKm314-B5-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/HKm314-B5-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/HKm314-B5-V.bcmap Binary files differnew file mode 100644 index 00000000000..0e96d0e228e --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/HKm314-B5-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/HKm471-B5-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/HKm471-B5-H.bcmap Binary files differnew file mode 100644 index 00000000000..11d170c75ed --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/HKm471-B5-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/HKm471-B5-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/HKm471-B5-V.bcmap Binary files differnew file mode 100644 index 00000000000..54959bf9e77 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/HKm471-B5-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/HKscs-B5-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/HKscs-B5-H.bcmap Binary files differnew file mode 100644 index 00000000000..6ef7857ad17 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/HKscs-B5-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/HKscs-B5-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/HKscs-B5-V.bcmap Binary files differnew file mode 100644 index 00000000000..1fb2fa2a2ec --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/HKscs-B5-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Hankaku.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Hankaku.bcmap Binary files differnew file mode 100644 index 00000000000..4b8ec7fcef4 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Hankaku.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Hiragana.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Hiragana.bcmap Binary files differnew file mode 100644 index 00000000000..17e983e7726 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Hiragana.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/KSC-EUC-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/KSC-EUC-H.bcmap Binary files differnew file mode 100644 index 00000000000..a45c65f008e --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/KSC-EUC-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/KSC-EUC-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/KSC-EUC-V.bcmap Binary files differnew file mode 100644 index 00000000000..0e7b21f0a61 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/KSC-EUC-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/KSC-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/KSC-H.bcmap Binary files differnew file mode 100644 index 00000000000..b9b22b67879 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/KSC-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/KSC-Johab-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/KSC-Johab-H.bcmap Binary files differnew file mode 100644 index 00000000000..2531ffcf41a --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/KSC-Johab-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/KSC-Johab-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/KSC-Johab-V.bcmap Binary files differnew file mode 100644 index 00000000000..367ceb226ab --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/KSC-Johab-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/KSC-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/KSC-V.bcmap Binary files differnew file mode 100644 index 00000000000..6ae2f0b6b72 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/KSC-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/KSCms-UHC-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/KSCms-UHC-H.bcmap Binary files differnew file mode 100644 index 00000000000..a8d4240e6ad --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/KSCms-UHC-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/KSCms-UHC-HW-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/KSCms-UHC-HW-H.bcmap Binary files differnew file mode 100644 index 00000000000..8b4ae18fd3e --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/KSCms-UHC-HW-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/KSCms-UHC-HW-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/KSCms-UHC-HW-V.bcmap Binary files differnew file mode 100644 index 00000000000..b655dbcfb12 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/KSCms-UHC-HW-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/KSCms-UHC-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/KSCms-UHC-V.bcmap Binary files differnew file mode 100644 index 00000000000..21f97f65b4a --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/KSCms-UHC-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/KSCpc-EUC-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/KSCpc-EUC-H.bcmap Binary files differnew file mode 100644 index 00000000000..e06f361eb6d --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/KSCpc-EUC-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/KSCpc-EUC-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/KSCpc-EUC-V.bcmap Binary files differnew file mode 100644 index 00000000000..f3c9113fcf0 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/KSCpc-EUC-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Katakana.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Katakana.bcmap Binary files differnew file mode 100644 index 00000000000..524303c4f0c --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Katakana.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/LICENSE b/addons/web/static/lib/pdfjs/external/bcmaps/LICENSE new file mode 100644 index 00000000000..b1ad168ad0d --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/LICENSE @@ -0,0 +1,36 @@ +%%Copyright: ----------------------------------------------------------- +%%Copyright: Copyright 1990-2009 Adobe Systems Incorporated. +%%Copyright: All rights reserved. +%%Copyright: +%%Copyright: Redistribution and use in source and binary forms, with or +%%Copyright: without modification, are permitted provided that the +%%Copyright: following conditions are met: +%%Copyright: +%%Copyright: Redistributions of source code must retain the above +%%Copyright: copyright notice, this list of conditions and the following +%%Copyright: disclaimer. +%%Copyright: +%%Copyright: Redistributions in binary form must reproduce the above +%%Copyright: copyright notice, this list of conditions and the following +%%Copyright: disclaimer in the documentation and/or other materials +%%Copyright: provided with the distribution. +%%Copyright: +%%Copyright: Neither the name of Adobe Systems Incorporated nor the names +%%Copyright: of its contributors may be used to endorse or promote +%%Copyright: products derived from this software without specific prior +%%Copyright: written permission. +%%Copyright: +%%Copyright: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +%%Copyright: CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +%%Copyright: INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +%%Copyright: MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +%%Copyright: DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +%%Copyright: CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +%%Copyright: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +%%Copyright: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +%%Copyright: LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +%%Copyright: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +%%Copyright: CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +%%Copyright: OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +%%Copyright: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +%%Copyright: ----------------------------------------------------------- diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/NWP-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/NWP-H.bcmap Binary files differnew file mode 100644 index 00000000000..afc5e4b05ee --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/NWP-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/NWP-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/NWP-V.bcmap Binary files differnew file mode 100644 index 00000000000..bb5785e3278 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/NWP-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/RKSJ-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/RKSJ-H.bcmap Binary files differnew file mode 100644 index 00000000000..fb8d298e9bb --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/RKSJ-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/RKSJ-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/RKSJ-V.bcmap Binary files differnew file mode 100644 index 00000000000..a2555a6c048 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/RKSJ-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/Roman.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/Roman.bcmap Binary files differnew file mode 100644 index 00000000000..f896dcf1c7f --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/Roman.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UCS2-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UCS2-H.bcmap Binary files differnew file mode 100644 index 00000000000..d5db27c5cf1 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UCS2-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UCS2-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UCS2-V.bcmap Binary files differnew file mode 100644 index 00000000000..1dc9b7a21bc --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UCS2-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF16-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF16-H.bcmap Binary files differnew file mode 100644 index 00000000000..961afefb66c --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF16-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF16-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF16-V.bcmap Binary files differnew file mode 100644 index 00000000000..df0cffe86b5 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF16-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF32-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF32-H.bcmap Binary files differnew file mode 100644 index 00000000000..1ab18a14367 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF32-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF32-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF32-V.bcmap Binary files differnew file mode 100644 index 00000000000..ad14662e25e --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF32-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF8-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF8-H.bcmap Binary files differnew file mode 100644 index 00000000000..83c6bd7c4ff --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF8-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF8-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF8-V.bcmap Binary files differnew file mode 100644 index 00000000000..22a27e4ddbe --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniCNS-UTF8-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UCS2-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UCS2-H.bcmap Binary files differnew file mode 100644 index 00000000000..5bd6228ce62 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UCS2-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UCS2-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UCS2-V.bcmap Binary files differnew file mode 100644 index 00000000000..53c534b7fec --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UCS2-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF16-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF16-H.bcmap Binary files differnew file mode 100644 index 00000000000..b95045b400a --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF16-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF16-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF16-V.bcmap Binary files differnew file mode 100644 index 00000000000..51f023e0d60 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF16-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF32-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF32-H.bcmap Binary files differnew file mode 100644 index 00000000000..f0dbd14f379 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF32-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF32-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF32-V.bcmap Binary files differnew file mode 100644 index 00000000000..ce9c30a9854 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF32-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF8-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF8-H.bcmap Binary files differnew file mode 100644 index 00000000000..982ca462b1b --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF8-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF8-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF8-V.bcmap Binary files differnew file mode 100644 index 00000000000..f78020dd402 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniGB-UTF8-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UCS2-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UCS2-H.bcmap Binary files differnew file mode 100644 index 00000000000..7daf56afabf --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UCS2-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UCS2-HW-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UCS2-HW-H.bcmap Binary files differnew file mode 100644 index 00000000000..ac9975c585e --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UCS2-HW-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UCS2-HW-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UCS2-HW-V.bcmap Binary files differnew file mode 100644 index 00000000000..3da0a1c62f1 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UCS2-HW-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UCS2-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UCS2-V.bcmap Binary files differnew file mode 100644 index 00000000000..c50b9ddfde9 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UCS2-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF16-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF16-H.bcmap Binary files differnew file mode 100644 index 00000000000..6761344639b --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF16-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF16-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF16-V.bcmap Binary files differnew file mode 100644 index 00000000000..70bf90c0efb --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF16-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF32-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF32-H.bcmap Binary files differnew file mode 100644 index 00000000000..7a83d53ae70 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF32-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF32-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF32-V.bcmap Binary files differnew file mode 100644 index 00000000000..7a871353949 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF32-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF8-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF8-H.bcmap Binary files differnew file mode 100644 index 00000000000..9f0334cac7f --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF8-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF8-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF8-V.bcmap Binary files differnew file mode 100644 index 00000000000..808a94f0fd9 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS-UTF8-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF16-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF16-H.bcmap Binary files differnew file mode 100644 index 00000000000..d768bf811ff --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF16-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF16-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF16-V.bcmap Binary files differnew file mode 100644 index 00000000000..3d5bf6fb4ef --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF16-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF32-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF32-H.bcmap Binary files differnew file mode 100644 index 00000000000..09eee10d4fb --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF32-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF32-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF32-V.bcmap Binary files differnew file mode 100644 index 00000000000..6c546001331 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF32-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF8-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF8-H.bcmap Binary files differnew file mode 100644 index 00000000000..1b1a64f50d2 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF8-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF8-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF8-V.bcmap Binary files differnew file mode 100644 index 00000000000..994aa9ef9f5 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJIS2004-UTF8-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJISPro-UCS2-HW-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJISPro-UCS2-HW-V.bcmap Binary files differnew file mode 100644 index 00000000000..643f921b658 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJISPro-UCS2-HW-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJISPro-UCS2-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJISPro-UCS2-V.bcmap Binary files differnew file mode 100644 index 00000000000..c148f67f5e9 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJISPro-UCS2-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJISPro-UTF8-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJISPro-UTF8-V.bcmap Binary files differnew file mode 100644 index 00000000000..1849d809a67 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJISPro-UTF8-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJISX0213-UTF32-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJISX0213-UTF32-H.bcmap Binary files differnew file mode 100644 index 00000000000..a83a677c56d --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJISX0213-UTF32-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJISX0213-UTF32-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJISX0213-UTF32-V.bcmap Binary files differnew file mode 100644 index 00000000000..f527248ad54 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJISX0213-UTF32-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJISX02132004-UTF32-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJISX02132004-UTF32-H.bcmap Binary files differnew file mode 100644 index 00000000000..e1a988dc9e8 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJISX02132004-UTF32-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniJISX02132004-UTF32-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniJISX02132004-UTF32-V.bcmap Binary files differnew file mode 100644 index 00000000000..47e054a961a --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniJISX02132004-UTF32-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UCS2-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UCS2-H.bcmap Binary files differnew file mode 100644 index 00000000000..b5b94852a57 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UCS2-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UCS2-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UCS2-V.bcmap Binary files differnew file mode 100644 index 00000000000..026adcaad4c --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UCS2-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF16-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF16-H.bcmap Binary files differnew file mode 100644 index 00000000000..fd4e66e81f3 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF16-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF16-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF16-V.bcmap Binary files differnew file mode 100644 index 00000000000..075efb70549 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF16-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF32-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF32-H.bcmap Binary files differnew file mode 100644 index 00000000000..769d2142c03 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF32-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF32-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF32-V.bcmap Binary files differnew file mode 100644 index 00000000000..bdab208b69d --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF32-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF8-H.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF8-H.bcmap Binary files differnew file mode 100644 index 00000000000..6ff8674af77 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF8-H.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF8-V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF8-V.bcmap Binary files differnew file mode 100644 index 00000000000..8dfa76a58eb --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/UniKS-UTF8-V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/V.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/V.bcmap Binary files differnew file mode 100644 index 00000000000..fdec9906621 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/V.bcmap diff --git a/addons/web/static/lib/pdfjs/external/bcmaps/WP-Symbol.bcmap b/addons/web/static/lib/pdfjs/external/bcmaps/WP-Symbol.bcmap Binary files differnew file mode 100644 index 00000000000..46729bbf30f --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/bcmaps/WP-Symbol.bcmap diff --git a/addons/web/static/lib/pdfjs/external/builder/builder.js b/addons/web/static/lib/pdfjs/external/builder/builder.js new file mode 100644 index 00000000000..c0d3da2976f --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/builder/builder.js @@ -0,0 +1,271 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +/* jshint node:true */ +/* globals cp, ls, test */ + +'use strict'; + +require('shelljs/make'); +var fs = require('fs'), + path = require('path'), + vm = require('vm'); + +/** + * A simple preprocessor that is based on the firefox preprocessor + * see (https://developer.mozilla.org/en/Build/Text_Preprocessor). The main + * difference is that this supports a subset of the commands and it supports + * preproccesor commands in html style comments. + * Currently Supported commands: + * - if + * - else + * - endif + * - include + * - expand + */ +function preprocess(inFilename, outFilename, defines) { + // TODO make this really read line by line. + var lines = fs.readFileSync(inFilename).toString().split('\n'); + var totalLines = lines.length; + var out = ''; + var i = 0; + function readLine() { + if (i < totalLines) { + return lines[i++]; + } + return null; + } + var writeLine = (typeof outFilename === 'function' ? outFilename : + function(line) { + out += line + '\n'; + }); + function include(file) { + var realPath = fs.realpathSync(inFilename); + var dir = path.dirname(realPath); + preprocess(path.join(dir, file), writeLine, defines); + } + function expand(line) { + line = line.replace(/__[\w]+__/g, function(variable) { + variable = variable.substring(2, variable.length - 2); + if (variable in defines) { + return defines[variable]; + } + return ''; + }); + writeLine(line); + } + + var s, state = 0, stack = []; + var control = + /^(?:\/\/|<!--)\s*#(if|else|endif|expand|include)(?:\s+(.*?)(?:-->)?$)?/; + var lineNumber = 0; + while ((s = readLine()) !== null) { + ++lineNumber; + var m = control.exec(s); + if (m) { + switch (m[1]) { + case 'if': + stack.push(state); + try { + state = vm.runInNewContext(m[2], defines) ? 3 : 1; + } catch (e) { + console.error('Could not evalute line \'' + m[2] + '\' at ' + + fs.realpathSync(inFilename) + ':' + lineNumber); + throw e; + } + break; + case 'else': + state = state === 1 ? 3 : 2; + break; + case 'endif': + state = stack.pop(); + break; + case 'expand': + if (state === 0 || state === 3) { + expand(m[2]); + } + break; + case 'include': + if (state === 0 || state === 3) { + include(m[2]); + } + break; + } + } else { + if (state === 0) { + writeLine(s); + } else if (state === 3) { + writeLine(s.replace(/^\/\/|^<!--|-->/g, ' ')); + } + } + } + if (state !== 0 || stack.length !== 0) { + throw new Error('Missing endif in preprocessor.'); + } + if (typeof outFilename !== 'function') { + fs.writeFileSync(outFilename, out); + } +} +exports.preprocess = preprocess; + +var deprecatedInMozcentral = new RegExp('(^|\\W)(' + [ + '-moz-box-sizing', + '-moz-grab', + '-moz-grabbing' + ].join('|') + ')'); + +function preprocessCSS(mode, source, destination) { + function hasPrefixedFirefox(line) { + return (/(^|\W)-(ms|o|webkit)-\w/.test(line)); + } + + function hasPrefixedMozcentral(line) { + return (/(^|\W)-(ms|o|webkit)-\w/.test(line) || + deprecatedInMozcentral.test(line)); + } + + function expandImports(content, baseUrl) { + return content.replace(/^\s*@import\s+url\(([^\)]+)\);\s*$/gm, + function(all, url) { + var file = path.join(path.dirname(baseUrl), url); + var imported = fs.readFileSync(file, 'utf8').toString(); + return expandImports(imported, file); + }); + } + + function removePrefixed(content, hasPrefixedFilter) { + var lines = content.split(/\r?\n/g); + var i = 0; + while (i < lines.length) { + var line = lines[i]; + if (!hasPrefixedFilter(line)) { + i++; + continue; + } + if (/\{\s*$/.test(line)) { + var bracketLevel = 1; + var j = i + 1; + while (j < lines.length && bracketLevel > 0) { + var checkBracket = /([{}])\s*$/.exec(lines[j]); + if (checkBracket) { + if (checkBracket[1] === '{') { + bracketLevel++; + } else if (lines[j].indexOf('{') < 0) { + bracketLevel--; + } + } + j++; + } + lines.splice(i, j - i); + } else if (/[};]\s*$/.test(line)) { + lines.splice(i, 1); + } else { + // multiline? skipping until next directive or bracket + do { + lines.splice(i, 1); + } while (i < lines.length && + !/\}\s*$/.test(lines[i]) && + lines[i].indexOf(':') < 0); + if (i < lines.length && /\S\s*}\s*$/.test(lines[i])) { + lines[i] = lines[i].substr(lines[i].indexOf('}')); + } + } + // collapse whitespaces + while (lines[i] === '' && lines[i - 1] === '') { + lines.splice(i, 1); + } + } + return lines.join('\n'); + } + + if (!mode) { + throw new Error('Invalid CSS preprocessor mode'); + } + + var content = fs.readFileSync(source, 'utf8').toString(); + content = expandImports(content, source); + if (mode === 'mozcentral' || mode === 'firefox') { + content = removePrefixed(content, mode === 'mozcentral' ? + hasPrefixedMozcentral : hasPrefixedFirefox); + } + fs.writeFileSync(destination, content); +} +exports.preprocessCSS = preprocessCSS; + +/** + * Simplifies common build steps. + * @param {object} setup + * .defines defines for preprocessors + * .copy array of arrays of source and destination pairs of files to copy + * .preprocess array of arrays of source and destination pairs of files + * run through preprocessor. + */ +function build(setup) { + var defines = setup.defines; + + setup.copy.forEach(function(option) { + var source = option[0]; + var destination = option[1]; + cp('-R', source, destination); + }); + + setup.preprocess.forEach(function(option) { + var sources = option[0]; + var destination = option[1]; + + sources = ls('-R', sources); + sources.forEach(function(source) { + // ??? Warn if the source is wildcard and dest is file? + var destWithFolder = destination; + if (test('-d', destination)) { + destWithFolder += '/' + path.basename(source); + } + preprocess(source, destWithFolder, defines); + }); + }); + + (setup.preprocessCSS || []).forEach(function(option) { + var mode = option[0]; + var source = option[1]; + var destination = option[2]; + preprocessCSS(mode, source, destination); + }); +} +exports.build = build; + +function getWorkerSrcFiles(filePath) { + var src = fs.readFileSync(filePath).toString(); + var reSrcFiles = /var\s+otherFiles\s*=\s*(\[[^\]]*\])/; + var match = reSrcFiles.exec(src); + try { + var files = JSON.parse(match[1].replace(/'/g, '"')); + var srcFiles = files.filter(function(name) { + return name.indexOf('external') === -1; + }); + var externalSrcFiles = files.filter(function(name) { + return name.indexOf('external') > -1; + }); + return { + srcFiles: srcFiles, + externalSrcFiles: externalSrcFiles + }; + } catch(e) { + return {}; + } +} +exports.getWorkerSrcFiles = getWorkerSrcFiles; + +/** + * Merge two defines arrays. Values in the second param will override values in + * the first. + */ +function merge(defaults, defines) { + var ret = {}; + for (var key in defaults) { + ret[key] = defaults[key]; + } + for (key in defines) { + ret[key] = defines[key]; + } + return ret; +} +exports.merge = merge; diff --git a/addons/web/static/lib/pdfjs/external/cmapscompress/README.md b/addons/web/static/lib/pdfjs/external/cmapscompress/README.md new file mode 100644 index 00000000000..9796eb20b9b --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/cmapscompress/README.md @@ -0,0 +1,171 @@ +# Quick notes about binary CMap format (bcmap) + +The format is designed to package some information from the CMap files located at external/cmap. Please notice for size optimization reasons, the original information blocks can be changed (split or joined) and items in the blocks can be swaped. + +The data stored in binary format in network byte order (big-endian). + +# Data primitives + +The following primitives used during encoding of the file: + - byte (B) – a byte, bits are numbered from 0 (less significant) to 7 (most significant) + - bytes block (B[n]) – a sequence of n bytes + - unsigned number (UN) – the number is encoded as sequence of bytes, bit 7 is flag to continue decoding the byte, bits 6-0 store number information, e.g. bytes 0x818407 will represent 16903 (0x4207). Limited to the 32 bit. + - signed number (SN) – the number is encoded as sequence of bytes, as UN, however shall be transformed before encoding: if n < 0, the n shall be encoded as (-2*n-1) using UN encoding, other n shall be encoded as (2*n) using UN encoding. So the lowest bit of the number indicates the sign of the initial number + - unsigned fixed number (UB[n]) – similar to the UN, but it represents an unsigned number that is stored in B[n] + - signed fixed number (SB[n]) – similar to the SN, but it represents a signed number that is stored in B[n] + - string (S) – the string is encoded as sequence of bytes. First comes length is characters encoded as UN, when UTF16 characters encoded as UN. + +# File structure + +The first byte is a header: + - bits 2-1 – indicate a CMapType. Valid values are 1 and 2 + - bit 0 – indicate WMode. Valid values are 0 and 1. + +Then records follow. The records starts from the record header encoded as B, where bits 7-5 indicate record type (see description of other bits below): + - 0 – codespacerange + - 1 – notdefrange + - 2 – cidchar + - 3 – cidrange + - 4 – bfchar + - 5 – bfrange + - 6 – reserved + - 7 – metadata + +## Metadata record + +The metadata record header bit 4-0 contain id of the metadata: + - 0 – comment, body of the record is encoded comment string (S) + - 1 – UseCMap, body of the record is usecmap id string (S) + +## Data records + +The records that have types 0 – 5, have the following fields in the header: + - bit 4 – indicate the char or start/end entries are stored in a sequence in this block + - bits 3-0 – contain length of the data size minus 1 in this block (dataSize) + +The amount of entries encoded as UN follows the header. The items records follow (see below). + + +### codespacerange (0) + +Represents the following CMap block: + + n begincodespacerange + <start> <end> + endcodespacerange + +First record format is: + + - start as B[dataSize] + - endDelta as UB[dataSize], end is calculated as (start + endDelta) + +Next record format is: + + - startDelta as UB[dataSize], start = end + startDelta + - endDelta as UB[dataSize], end = start + endDelta + + +### notdefrange (1) + +Represents the following CMap block: + + n beginnotdefrange + <start> <end> code + endnotdefrange + +First record format is: + + - start as B[dataSize] + - endDelta as UB[dataSize], end is calculated as (start + endDelta) + - code as UN + +Next record format is: + + - startDelta as UB[dataSize], start = end + startDelta + - endDelta as UB[dataSize], end = start + endDelta + - code as UN + + +### cidchar (2) + +Represents the following CMap block: + + n begincidchar + <char> code + endcidchar + +First record format is: + + - char as B[dataSize] + - code as UN + +Next record format is: + + - if sequence = 0, charDelta as UB[dataSize], char = char + charDelta + 1 + - if sequence = 1, char = char + 1 + - codeDelta as SN, code = code + codeDelta + + +### cidrange (3) + +Represents the following CMap block: + + n begincidrange + <start> <end> code + endcidrange + +First record format is: + + - start as B[dataSize] + - endDelta as UN[dataSize], end is calculated as (start + endDelta) + - code as UN + +Next record format is: + + - if sequence = 0, startDelta as UB[dataSize], start = end + startDelta + 1 + - if sequence = 1, start = end + 1 + - endDelta as UN[dataSize], end = start + endDelta + - code as UN + + +### bfchar (4) + +Represents the following CMap block: + + n beginbfchar + <char> <code> + endbfchar + +First record format is: + + - char as B[ucs2Size], where ucs2Size = 2 (here and below) + - code as B[dataSize] + +Next record format is: + + - if sequence = 0, charDelta as UN[ucs2Size], char = charDelta + charDelta + 1 + - if sequence = 1, char = char + 1 + - codeDelta as SB[dataSize], code = code + codeDelta + + +### bfrange (5) + +Represents the following CMap block: + + n beginbfrange + <start> <end> <code> + endbfrange + +First record format is: + + - start as B[ucs2Size] + - endDelta as UB[ucs2Size], end is calculated as (start + endDelta) + - code as B[dataSize] + +Next record format is: + + - if sequence = 0, startDelta as UB[ucs2Size], start = end + startDelta + 1 + - if sequence = 1, start = end + 1 + - endDelta as UB[ucs2Size], end = start + endDelta + - code as B[dataSize] + diff --git a/addons/web/static/lib/pdfjs/external/cmapscompress/compress.js b/addons/web/static/lib/pdfjs/external/cmapscompress/compress.js new file mode 100644 index 00000000000..078cfe63f28 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/cmapscompress/compress.js @@ -0,0 +1,437 @@ +/* Copyright 2014 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var fs = require('fs'); +var path = require('path'); +var parseAdobeCMap = require('./parse.js').parseAdobeCMap; +var optimizeCMap = require('./optimize.js').optimizeCMap; + +function compressCmap(srcPath, destPath, verify) { + var content = fs.readFileSync(srcPath).toString(); + var inputData = parseAdobeCMap(content); + optimizeCMap(inputData); + + var out = writeByte((inputData.type << 1) | inputData.wmode); + if (inputData.comment) { + out += writeByte(0xE0) + writeString(inputData.comment); + } + if (inputData.usecmap) { + out += writeByte(0xE1) + writeString(inputData.usecmap); + } + var i = 0; + while (i < inputData.body.length) { + var item = inputData.body[i++], subitems = item.items; + var first = item.items[0]; + var sequence = item.sequence === true; + var flags = (item.type << 5) | (sequence ? 0x10 : 0); + var nextStart, nextCode; + switch (item.type) { + case 0: + out += writeByte(flags | getHexSize(first.start)) + writeNumber(subitems.length); + out += first.start + writeNumber(subHex(first.end, first.start)); + nextStart = incHex(first.end); + for (var j = 1; j < subitems.length; j++) { + out += writeNumber(subHex(subitems[j].start, nextStart)) + + writeNumber(subHex(subitems[j].end, subitems[j].start)); + nextStart = incHex(subitems[j].end); + } + break; + case 1: + out += writeByte(flags | getHexSize(first.start)) + writeNumber(subitems.length); + out += first.start + writeNumber(subHex(first.end, first.start)) + writeNumber(first.code); + nextStart = incHex(first.end); + for (var j = 1; j < subitems.length; j++) { + out += writeNumber(subHex(subitems[j].start, nextStart)) + + writeNumber(subHex(subitems[j].end, subitems[j].start)) + + writeNumber(subitems[j].code); + nextStart = incHex(subitems[j].end); + } + break; + case 2: + out += writeByte(flags | getHexSize(first.char)) + writeNumber(subitems.length); + out += first.char + writeNumber(first.code); + nextStart = incHex(first.char); + nextCode = first.code + 1; + for (var j = 1; j < subitems.length; j++) { + out += (sequence ? '' : writeNumber(subHex(subitems[j].char, nextStart))) + + writeSigned(subitems[j].code - nextCode); + nextStart = incHex(subitems[j].char); + nextCode = item.items[j].code + 1; + } + break; + case 3: + out += writeByte(flags | getHexSize(first.start)) + writeNumber(subitems.length); + out += first.start + writeNumber(subHex(first.end, first.start)) + writeNumber(first.code); + nextStart = incHex(first.end); + for (var j = 1; j < subitems.length; j++) { + out += (sequence ? '' : writeNumber(subHex(subitems[j].start, nextStart))) + + writeNumber(subHex(subitems[j].end, subitems[j].start)) + + writeNumber(subitems[j].code); + nextStart = incHex(subitems[j].end); + } + break; + case 4: + out += writeByte(flags | getHexSize(first.code)) + writeNumber(subitems.length); + out += first.char + first.code; + nextStart = incHex(first.char); + nextCode = incHex(first.code); + for (var j = 1; j < subitems.length; j++) { + out += (sequence ? '' : writeNumber(subHex(subitems[j].char, nextStart))) + + writeSigned(subHex(subitems[j].code, nextCode)); + nextStart = incHex(subitems[j].char); + nextCode = incHex(subitems[j].code); + } + break; + case 5: + out += writeByte(flags | getHexSize(first.code)) + writeNumber(subitems.length); + out += first.start + writeNumber(subHex(first.end, first.start)) + first.code; + nextStart = incHex(first.end); + for (var j = 1; j < subitems.length; j++) { + out += (sequence ? '' : writeNumber(subHex(subitems[j].start, nextStart))) + + writeNumber(subHex(subitems[j].end, subitems[j].start)) + + subitems[j].code; + nextStart = incHex(subitems[j].end); + } + break; + + } + } + + fs.writeFileSync(destPath, new Buffer(out, 'hex')); + + if (verify) { + var result2 = parseCMap(out); + var isGood = JSON.stringify(inputData) == JSON.stringify(result2); + if (!isGood) { + throw new Error('Extracted data does not match the expected result'); + } + } + + return { + orig: fs.statSync(srcPath).size, + packed: out.length >> 1 + }; +} + +function parseCMap(binaryData) { + var reader = { + buffer: binaryData, + pos: 0, + end: binaryData.length, + readByte: function () { + if (this.pos >= this.end) { + return -1; + } + var d1 = fromHexDigit(this.buffer[this.pos]); + var d2 = fromHexDigit(this.buffer[this.pos + 1]); + this.pos += 2; + return (d1 << 4) | d2; + }, + readNumber: function () { + var n = 0; + var last; + do { + var b = this.readByte(); + last = !(b & 0x80); + n = (n << 7) | (b & 0x7F); + } while (!last); + return n; + }, + readSigned: function () { + var n = this.readNumber(); + return (n & 1) ? -(n >>> 1) - 1 : n >>> 1; + }, + readHex: function (size) { + var lengthInChars = (size + 1) << 1; + var s = this.buffer.substr(this.pos, lengthInChars); + this.pos += lengthInChars; + return s; + }, + readHexNumber: function (size) { + var lengthInChars = (size + 1) << 1; + var stack = []; + do { + var b = this.readByte(); + last = !(b & 0x80); + stack.push(b & 0x7F); + } while (!last); + var s = '', buffer = 0, bufferSize = 0; + while (s.length < lengthInChars) { + while (bufferSize < 4 && stack.length > 0) { + buffer = (stack.pop() << bufferSize) | buffer; + bufferSize += 7; + } + s = toHexDigit(buffer & 15) + s; + buffer >>= 4; + bufferSize -= 4; + } + return s; + }, + readHexSigned: function (size) { + var num = this.readHexNumber(size); + var sign = fromHexDigit(num[num.length - 1]) & 1 ? 15 : 0; + var c = 0; + var result = ''; + for (var i = 0; i < num.length; i++) { + c = (c << 4) | fromHexDigit(num[i]); + result += toHexDigit(sign ? (c >> 1) ^ sign : (c >> 1)); + c &= 1; + } + return result; + }, + readString: function () { + var len = this.readNumber(); + var s = ''; + for (var i = 0; i < len; i++) { + s += String.fromCharCode(this.readNumber()); + } + return s; + } + }; + + var header = reader.readByte(); + var result = { + type: header >> 1, + wmode: header & 1, + comment: null, + usecmap: null, + body: [] + }; + + var b; + while ((b = reader.readByte()) >= 0) { + var type = b >> 5; + if (type === 7) { + switch (b & 0x1F) { + case 0: + result.comment = reader.readString(); + break; + case 1: + result.usecmap = reader.readString(); + break; + } + continue; + } + var sequence = !!(b & 0x10); + var dataSize = b & 15; + var subitems = []; + var item = { + type: type, + items: subitems + }; + if (sequence) { + item.sequence = true; + } + var ucs2DataSize = 1; + var subitemsCount = reader.readNumber(); + var start, end, code, char; + switch (type) { + case 0: + start = reader.readHex(dataSize); + end = addHex(reader.readHexNumber(dataSize), start); + subitems.push({start: start, end: end}); + for (var i = 1; i < subitemsCount; i++) { + start = addHex(reader.readHexNumber(dataSize), incHex(end)); + end = addHex(reader.readHexNumber(dataSize), start); + subitems.push({start: start, end: end}); + } + break; + case 1: + start = reader.readHex(dataSize); + end = addHex(reader.readHexNumber(dataSize), start); + code = reader.readNumber(); + subitems.push({start: start, end: end, code: code}); + for (var i = 1; i < subitemsCount; i++) { + start = addHex(reader.readHexNumber(dataSize), incHex(end)); + end = addHex(reader.readHexNumber(dataSize), start); + code = reader.readNumber(); + subitems.push({start: start, end: end, code: code}); + } + break; + case 2: + char = reader.readHex(dataSize); + code = reader.readNumber(); + subitems.push({char: char, code: code}); + for (var i = 1; i < subitemsCount; i++) { + char = sequence ? incHex(char) : addHex(reader.readHexNumber(dataSize), incHex(char)); + code = reader.readSigned() + (code + 1); + subitems.push({char: char, code: code}); + } + break; + case 3: + start = reader.readHex(dataSize); + end = addHex(reader.readHexNumber(dataSize), start); + code = reader.readNumber(); + subitems.push({start: start, end: end, code: code}); + for (var i = 1; i < subitemsCount; i++) { + start = sequence ? incHex(end) : addHex(reader.readHexNumber(dataSize), incHex(end)); + end = addHex(reader.readHexNumber(dataSize), start); + code = reader.readNumber(); + subitems.push({start: start, end: end, code: code}); + } + break; + case 4: + char = reader.readHex(ucs2DataSize); + code = reader.readHex(dataSize); + subitems.push({char: char, code: code}); + for (var i = 1; i < subitemsCount; i++) { + char = sequence ? incHex(char) : addHex(reader.readHexNumber(ucs2DataSize), incHex(char)); + code = addHex(reader.readHexSigned(dataSize), incHex(code)); + subitems.push({char: char, code: code}); + } + break; + case 5: + start = reader.readHex(ucs2DataSize); + end = addHex(reader.readHexNumber(ucs2DataSize), start); + code = reader.readHex(dataSize); + subitems.push({start: start, end: end, code: code}); + for (var i = 1; i < subitemsCount; i++) { + start = sequence ? incHex(end) : addHex(reader.readHexNumber(ucs2DataSize), incHex(end)); + end = addHex(reader.readHexNumber(ucs2DataSize), start); + code = reader.readHex(dataSize); + subitems.push({start: start, end: end, code: code}); + } + break; + default: + throw new Error('Unknown type: ' + type) + } + result.body.push(item); + } + + return result; +} + +function toHexDigit(n) { + return n.toString(16); +} +function fromHexDigit(s) { + return parseInt(s, 16); +} +function getHexSize(s) { + return (s.length >> 1) - 1; +} +function writeByte(b) { + return toHexDigit((b >> 4) & 15) + toHexDigit(b & 15); +} +function writeNumber(n) { + if (typeof n === 'string') { + var s = '', buffer = 0, bufferSize = 0; + var i = n.length; + while (i > 0) { + --i; + buffer = (fromHexDigit(n[i]) << bufferSize) | buffer; + bufferSize += 4; + if (bufferSize >= 7) { + s = writeByte((buffer & 0x7f) | (s.length > 0 ? 0x80 : 0)) + s; + buffer >>>= 7; + bufferSize -= 7; + } + } + if (buffer > 0) { + s = writeByte((buffer & 0x7f) | (s.length > 0 ? 0x80 : 0)) + s; + } + while (s.indexOf('80') === 0) { + s = s.substr(2); + } + return s; + } else { + var s = writeByte(n & 0x7F); + n >>>= 7; + while (n > 0) { + s = writeByte((n & 0x7F) | 0x80) + s; + n >>>= 7; + } + return s; + } +} +function writeSigned(n) { + if (typeof n === 'string') { + var t = ''; + var c = fromHexDigit(n[0]); + var neg = c >= 8; + c = neg ? (c ^ 15) : c; + for (var i = 1; i < n.length; i++) { + var d = fromHexDigit(n[i]); + c = (c << 4) | (neg ? (d ^ 15) : d); + t += toHexDigit(c >> 3); + c = c & 7; + } + t += toHexDigit((c << 1) | (neg ? 1 : 0)); + return writeNumber(t); + } + return n < 0 ? writeNumber(-2 * n - 1) : writeNumber(2 * n); +} +function writeString(s) { + var t = writeNumber(s.length); + for (var i = 0; i < s.length; i++) { + t += writeNumber(s.charCodeAt(i)); + } + return t; +} +function addHex(a, b) { + var c = 0, s = ''; + for (var i = a.length - 1; i >= 0; i--) { + c += fromHexDigit(a[i]) + fromHexDigit(b[i]); + if (c >= 16) { + s = toHexDigit(c - 16) + s; + c = 1; + } else { + s = toHexDigit(c) + s; + c = 0; + } + } + return s; +} +function subHex(a, b) { + var c = 0, s = ''; + for (var i = a.length - 1; i >= 0; i--) { + c += fromHexDigit(a[i]) - fromHexDigit(b[i]); + if (c < 0) { + s = toHexDigit(c + 16) + s; + c = -1; + } else { + s = toHexDigit(c) + s; + c = 0; + } + } + return s; +} +function incHex(a) { + var c = 1, s = ''; + for (var i = a.length - 1; i >= 0; i--) { + c += fromHexDigit(a[i]); + if (c >= 16) { + s = toHexDigit(c - 16) + s; + c = 1; + } else { + s = toHexDigit(c) + s; + c = 0; + } + } + return s; +} + +exports.compressCmaps = function (src, dest, verify) { + var files = fs.readdirSync(src).filter(function (fn) { + return fn.indexOf('.') < 0; // skipping files with the extension + }); + files.forEach(function (fn) { + var srcPath = path.join(src, fn); + var destPath = path.join(dest, fn + '.bcmap'); + var stats = compressCmap(srcPath, destPath, verify); + console.log('Compressing ' + fn + ': ' + stats.orig + ' vs ' + stats.packed + + ' ' + (stats.packed / stats.orig * 100).toFixed(1) + '%'); + }); +}; diff --git a/addons/web/static/lib/pdfjs/external/cmapscompress/optimize.js b/addons/web/static/lib/pdfjs/external/cmapscompress/optimize.js new file mode 100644 index 00000000000..1252b9a2719 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/cmapscompress/optimize.js @@ -0,0 +1,211 @@ +/* Copyright 2014 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +exports.optimizeCMap = function (data) { + var i = 1; + while (i < data.body.length) { + if (data.body[i - 1].type === data.body[i].type) { + data.body[i - 1].items = data.body[i - 1].items.concat(data.body[i].items); + data.body.splice(i, 1); + } else { + i++; + } + } + // split into groups with different lengths + var i = 0; + while (i < data.body.length) { + var item = data.body[i]; + var keys = Object.keys(item.items[0]).filter(function (i) { + return typeof item.items[0][i] === 'string'; + }); + var j = 1; + while (j < item.items.length) { + var different = false; + for (var q = 0; q < keys.length && !different; q++) { + different = item.items[j - 1][keys[q]].length !== item.items[j][keys[q]].length; + } + if (different) { + break; + } + j++; + } + if (j < item.items.length) { + data.body.splice(i + 1, 0, { + type: item.type, + items: item.items.splice(j, item.items.length - j) + }); + } + i++; + } + // find sequences of single char ranges + var i = 0; + while (i < data.body.length) { + var item = data.body[i]; + if (item.type === 3 || item.type === 5) { + var j = 0; + while (j < item.items.length) { + var q = j; + while (j < item.items.length && item.items[j].start === item.items[j].end) { + j++; + } + if ((j - q) >= 9) { + if (j < item.items.length) { + data.body.splice(i + 1, 0, { + type: item.type, + items: item.items.splice(j, item.items.length - j) + }); + } + if (q > 0) { + data.body.splice(i + 1, 0, { + type: item.type - 1, + items: item.items.splice(q, j - q).map(function (i) { + return {char: i.start, code: i.code }; + }) + }); + i++; + } else { + item.type -= 1; + item.items = item.items.map(function (i) { + return {char: i.start, code: i.code }; + }); + } + continue; + } + j++; + } + } + i++; + } + + // find sequences of increasing code/ranges order + var i = 0; + while (i < data.body.length) { + var item = data.body[i]; + if (item.type >= 2 && item.type <= 5) { + var j = 1; + var startProp = item.type === 2 || item.type === 4 ? 'char' : 'start'; + var endProp = item.type === 2 || item.type === 4 ? 'char' : 'end'; + while (j < item.items.length) { + var q = j - 1; + while (j < item.items.length && incHex(item.items[j - 1][endProp]) === item.items[j][startProp]) { + j++; + } + if ((j - q) >= 9) { + if (j < item.items.length) { + data.body.splice(i + 1, 0, { + type: item.type, + items: item.items.splice(j, item.items.length - j) + }); + } + if (q > 0) { + data.body.splice(i + 1, 0, { + type: item.type, + items: item.items.splice(q, j - q), + sequence: true + }); + i++; + } else { + item.sequence = true; + } + continue; + } + j++; + } + } + i++; + } + + // split non-sequences two groups where codes are close + var i = 0; + while (i < data.body.length) { + var item = data.body[i]; + if (!item.sequence && (item.type === 2 || item.type === 3)) { + var subitems = item.items; + var codes = subitems.map(function (i) { + return i.code; + }); + codes.sort(function (a, b) { + return a - b; + }); + var maxDistance = 100, minItems = 10, itemsPerBucket = 50; + if (subitems.length > minItems && codes[codes.length - 1] - codes[0] > maxDistance) { + var gapsCount = Math.max(2, (subitems.length / itemsPerBucket) | 0); + var gaps = []; + for (var q = 0; q < gapsCount; q++) { + gaps.push({length: 0}); + } + for (var j = 1; j < codes.length; j++) { + var gapLength = codes[j] - codes[j - 1]; + var q = 0; + while (q < gaps.length && gaps[q].length > gapLength) { + q++; + } + if (q >= gaps.length) { + continue; + } + var q0 = q; + while (q < gaps.length) { + if (gaps[q].length < gaps[q0].length) { + q0 = q; + } + q++; + } + gaps[q0] = {length: gapLength, boundary: codes[j]}; + } + var groups = gaps.filter(function (g) { + return g.length >= maxDistance; + }).map(function (g) { + return g.boundary; + }); + groups.sort(function (a, b) { + return a - b; + }); + if (groups.length > 1) { + var buckets = [item.items = []]; + for (var j = 0; j < groups.length; j++) { + var newItem = {type: item.type, items: []} + buckets.push(newItem.items); + i++; + data.body.splice(i, 0, newItem); + } + for (var j = 0; j < subitems.length; j++) { + var code = subitems[j].code; + var q = 0; + while (q < groups.length && groups[q] <= code) { + q++; + } + buckets[q].push(subitems[j]); + } + } + } + } + i++; + } +}; + +function incHex(a) { + var c = 1, s = ''; + for (var i = a.length - 1; i >= 0; i--) { + c += parseInt(a[i], 16); + if (c >= 16) { + s = '0' + s; + c = 1; + } else { + s = c.toString(16) + s; + c = 0; + } + } + return s; +} diff --git a/addons/web/static/lib/pdfjs/external/cmapscompress/parse.js b/addons/web/static/lib/pdfjs/external/cmapscompress/parse.js new file mode 100644 index 00000000000..acb87b9e5bc --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/cmapscompress/parse.js @@ -0,0 +1,101 @@ +/* Copyright 2014 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +exports.parseAdobeCMap = function (content) { + var m = /(\bbegincmap\b[\s\S]*?)\bendcmap\b/.exec(content); + if (!m) { + throw new Error('cmap was not found'); + } + + var body = m[1].replace(/\r\n?/g, '\n'); + var result = { + type: 1, + wmode: 0, + comment: 'Copyright 1990-2009 Adobe Systems Incorporated.\nAll rights reserved.\nSee ./LICENSE', + usecmap: null, + body: [] + }; + m = /\/CMapType\s+(\d+)+\s+def\b/.exec(body); + result.type = +m[1]; + m = /\/WMode\s+(\d+)+\s+def\b/.exec(body); + result.wmode = +m[1]; + m = /\/([\w\-]+)\s+usecmap\b/.exec(body); + if (m) { + result.usecmap = m[1]; + } + var re = /(\d+)\s+(begincodespacerange|beginnotdefrange|begincidchar|begincidrange|beginbfchar|beginbfrange)\n([\s\S]*?)\n(endcodespacerange|endnotdefrange|endcidchar|endcidrange|endbfchar|endbfrange)/g; + while (m = re.exec(body)) { + var lines = m[3].toLowerCase().split('\n'); + var m2; + switch (m[2]) { + case 'begincodespacerange': + result.body.push({ + type: 0, + items: lines.map(function (line) { + var m = /<(\w+)>\s+<(\w+)>/.exec(line); + return {start: m[1], end: m[2]}; + }) + }); + break; + case 'beginnotdefrange': + result.body.push({ + type: 1, + items: lines.map(function (line) { + var m = /<(\w+)>\s+<(\w+)>\s+(\d+)/.exec(line); + return {start: m[1], end: m[2], code: +m[3]}; + }) + }); + break; + case 'begincidchar': + result.body.push({ + type: 2, + items: lines.map(function (line) { + var m = /<(\w+)>\s+(\d+)/.exec(line); + return {char: m[1], code: +m[2]}; + }) + }); + break; + case 'begincidrange': + result.body.push({ + type: 3, + items: lines.map(function (line) { + var m = /<(\w+)>\s+<(\w+)>\s+(\d+)/.exec(line); + return {start: m[1], end: m[2], code: +m[3]}; + }) + }); + break; + case 'beginbfchar': + result.body.push({ + type: 4, + items: lines.map(function (line) { + var m = /<(\w+)>\s+<(\w+)>/.exec(line); + return {char: m[1], code: m[2]}; + }) + }); + break; + case 'beginbfrange': + result.body.push({ + type: 5, + items: lines.map(function (line) { + var m = /<(\w+)>\s+<(\w+)>\s+<(\w+)>/.exec(line); + return {start: m[1], end: m[2], code: m[3]}; + }) + }); + break; + } + } + + return result; +};
\ No newline at end of file diff --git a/addons/web/static/lib/pdfjs/external/crlfchecker/crlfchecker.js b/addons/web/static/lib/pdfjs/external/crlfchecker/crlfchecker.js new file mode 100644 index 00000000000..f36894934ae --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/crlfchecker/crlfchecker.js @@ -0,0 +1,29 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +/* jshint node:true */ +/* globals cat, echo, exit, ls */ + +'use strict'; + +function checkIfCrlfIsPresent(files) { + var failed = []; + + (ls(files)).forEach(function checkCrlf(file) { + if ((cat(file)).match(/.*\r.*/)) { + failed.push(file); + } + }); + + if (failed.length) { + var errorMessage = + 'Please remove carriage return\'s from\n' + failed.join('\n') + '\n' + + 'Also check your setting for: git config core.autocrlf.'; + + echo(); + echo(errorMessage); + exit(1); + } +} + +exports.checkIfCrlfIsPresent = checkIfCrlfIsPresent; + diff --git a/addons/web/static/lib/pdfjs/external/crlfchecker/normtext.js b/addons/web/static/lib/pdfjs/external/crlfchecker/normtext.js new file mode 100644 index 00000000000..3bfda0f1f45 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/crlfchecker/normtext.js @@ -0,0 +1,33 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +/* Copyright 2012 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* jshint node:true */ + +'use strict'; + +var fs = require('fs'); + +function normalizeText(s) { + return s.replace(/\r\n?/g, '\n').replace(/\uFEFF/g, ''); +} + +var args = process.argv.slice(2); + +args.forEach(function (file) { + var content = fs.readFileSync(file, 'utf8'); + content = normalizeText(content); + fs.writeFileSync(file, content, 'utf8'); +}); diff --git a/addons/web/static/lib/pdfjs/external/dist/README.md b/addons/web/static/lib/pdfjs/external/dist/README.md new file mode 100644 index 00000000000..daef282c17f --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/dist/README.md @@ -0,0 +1,10 @@ +# PDF.js + +PDF.js is a Portable Document Format (PDF) library that is built with HTML5. +Our goal is to create a general-purpose, web standards-based platform for +parsing and rendering PDFs. + +This is a pre-built version of the PDF.js source code. It is automatically +generated by the build scripts. + +See https://github.com/mozilla/pdf.js for learning and contributing. diff --git a/addons/web/static/lib/pdfjs/external/importL10n/locales.js b/addons/web/static/lib/pdfjs/external/importL10n/locales.js new file mode 100644 index 00000000000..f37e8cfe110 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/importL10n/locales.js @@ -0,0 +1,96 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ +/* Copyright 2012 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* jshint node:true */ + +'use strict'; + +var fs = require('fs'); +var http = require('http'); +var path = require('path'); + +// Defines all languages that have a translation at mozilla-aurora. +// This is used in make.js for the importl10n command. +var langCodes = [ + 'ach', 'af', 'ak', 'an', 'ar', 'as', 'ast', 'az', 'be', 'bg', + 'bn-BD', 'bn-IN', 'br', 'bs', 'ca', 'cs', 'csb', 'cy', 'da', + 'de', 'el', 'en-GB', 'en-ZA', 'eo', 'es-AR', 'es-CL', 'es-ES', + 'es-MX', 'et', 'eu', 'fa', 'ff', 'fi', 'fr', 'fy-NL', 'ga-IE', + 'gd', 'gl', 'gu-IN', 'he', 'hi-IN', 'hr', 'hu', 'hy-AM', 'id', + 'is', 'it', 'ja', 'ka', 'kk', 'km', 'kn', 'ko', 'ku', 'lg', + 'lij', 'lt', 'lv', 'mai', 'mk', 'ml', 'mn', 'mr', 'ms', 'my', + 'nb-NO', 'nl', 'nn-NO', 'nso', 'oc', 'or', 'pa-IN', 'pl', + 'pt-BR', 'pt-PT', 'rm', 'ro', 'ru', 'rw', 'sah', 'si', 'sk', + 'sl', 'son', 'sq', 'sr', 'sv-SE', 'sw', 'ta', 'ta-LK', 'te', + 'th', 'tl', 'tn', 'tr', 'uk', 'ur', 'vi', 'wo', 'xh', 'zh-CN', + 'zh-TW', 'zu' +]; + +function normalizeText(s) { + return s.replace(/\r\n?/g, '\n').replace(/\uFEFF/g, ''); +} + +function downloadLanguageFiles(langCode, callback) { + console.log('Downloading ' + langCode + '...'); + + // Constants for constructing the URLs. Translations are taken from the + // Aurora channel as those are the most recent ones. The Nightly channel + // does not provide all translations. + var MOZCENTRAL_ROOT = 'http://mxr.mozilla.org/l10n-mozilla-aurora/source/'; + var MOZCENTRAL_PDFJS_DIR = '/browser/pdfviewer/'; + var MOZCENTRAL_RAW_FLAG = '?raw=1'; + + // Defines which files to download for each language. + var files = ['chrome.properties', 'viewer.properties']; + var downloadsLeft = files.length; + + if (!fs.existsSync(langCode)) { + fs.mkdirSync(langCode); + } + + // Download the necessary files for this language. + files.forEach(function(fileName) { + var outputPath = path.join(langCode, fileName); + var url = MOZCENTRAL_ROOT + langCode + MOZCENTRAL_PDFJS_DIR + + fileName + MOZCENTRAL_RAW_FLAG; + var request = http.get(url, function(response) { + var content = ''; + response.setEncoding('utf8'); + response.on("data", function(chunk) { + content += chunk; + }); + response.on('end', function() { + fs.writeFileSync(outputPath, normalizeText(content), 'utf8'); + downloadsLeft--; + if (downloadsLeft === 0) { + callback(); + } + }) + }); + }); +} + +function downloadL10n() { + var i = 0; + (function next() { + if (i >= langCodes.length) { + return; + } + downloadLanguageFiles(langCodes[i++], next); + })(); +} + +exports.downloadL10n = downloadL10n; diff --git a/addons/web/static/lib/pdfjs/external/jasmine/MIT.LICENSE b/addons/web/static/lib/pdfjs/external/jasmine/MIT.LICENSE new file mode 100644 index 00000000000..7c435baaec8 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/jasmine/MIT.LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2008-2011 Pivotal Labs + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/addons/web/static/lib/pdfjs/external/jasmine/jasmine-html.js b/addons/web/static/lib/pdfjs/external/jasmine/jasmine-html.js new file mode 100644 index 00000000000..3de4e8a5f15 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/jasmine/jasmine-html.js @@ -0,0 +1,676 @@ +jasmine.HtmlReporterHelpers = {}; + +jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) { + var el = document.createElement(type); + + for (var i = 2; i < arguments.length; i++) { + var child = arguments[i]; + + if (typeof child === 'string') { + el.appendChild(document.createTextNode(child)); + } else { + if (child) { + el.appendChild(child); + } + } + } + + for (var attr in attrs) { + if (attr == "className") { + el[attr] = attrs[attr]; + } else { + el.setAttribute(attr, attrs[attr]); + } + } + + return el; +}; + +jasmine.HtmlReporterHelpers.getSpecStatus = function(child) { + var results = child.results(); + var status = results.passed() ? 'passed' : 'failed'; + if (results.skipped) { + status = 'skipped'; + } + + return status; +}; + +jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) { + var parentDiv = this.dom.summary; + var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite'; + var parent = child[parentSuite]; + + if (parent) { + if (typeof this.views.suites[parent.id] == 'undefined') { + this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views); + } + parentDiv = this.views.suites[parent.id].element; + } + + parentDiv.appendChild(childElement); +}; + + +jasmine.HtmlReporterHelpers.addHelpers = function(ctor) { + for(var fn in jasmine.HtmlReporterHelpers) { + ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn]; + } +}; + +jasmine.HtmlReporter = function(_doc) { + var self = this; + var doc = _doc || window.document; + + var reporterView; + + var dom = {}; + + // Jasmine Reporter Public Interface + self.logRunningSpecs = false; + + self.reportRunnerStarting = function(runner) { + var specs = runner.specs() || []; + + if (specs.length == 0) { + return; + } + + createReporterDom(runner.env.versionString()); + doc.body.appendChild(dom.reporter); + + reporterView = new jasmine.HtmlReporter.ReporterView(dom); + reporterView.addSpecs(specs, self.specFilter); + }; + + self.reportRunnerResults = function(runner) { + reporterView.complete(); + }; + + self.reportSuiteResults = function(suite) { + reporterView.suiteComplete(suite); + }; + + self.reportSpecStarting = function(spec) { + if (self.logRunningSpecs) { + self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...'); + } + }; + + self.reportSpecResults = function(spec) { + reporterView.specComplete(spec); + }; + + self.log = function() { + var console = jasmine.getGlobal().console; + if (console && console.log) { + if (console.log.apply) { + console.log.apply(console, arguments); + } else { + console.log(arguments); // ie fix: console.log.apply doesn't exist on ie + } + } + }; + + self.specFilter = function(spec) { + if (!focusedSpecName()) { + return true; + } + + return spec.getFullName().indexOf(focusedSpecName()) === 0; + }; + + return self; + + function focusedSpecName() { + var specName; + + (function memoizeFocusedSpec() { + if (specName) { + return; + } + + var paramMap = []; + var params = doc.location.search.substring(1).split('&'); + + for (var i = 0; i < params.length; i++) { + var p = params[i].split('='); + paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); + } + + specName = paramMap.spec; + })(); + + return specName; + } + + function createReporterDom(version) { + dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' }, + dom.banner = self.createDom('div', { className: 'banner' }, + self.createDom('span', { className: 'title' }, "Jasmine "), + self.createDom('span', { className: 'version' }, version)), + + dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}), + dom.alert = self.createDom('div', {className: 'alert'}), + dom.results = self.createDom('div', {className: 'results'}, + dom.summary = self.createDom('div', { className: 'summary' }), + dom.details = self.createDom('div', { id: 'details' })) + ); + } +}; +jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);jasmine.HtmlReporterHelpers = {}; + +jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) { + var el = document.createElement(type); + + for (var i = 2; i < arguments.length; i++) { + var child = arguments[i]; + + if (typeof child === 'string') { + el.appendChild(document.createTextNode(child)); + } else { + if (child) { + el.appendChild(child); + } + } + } + + for (var attr in attrs) { + if (attr == "className") { + el[attr] = attrs[attr]; + } else { + el.setAttribute(attr, attrs[attr]); + } + } + + return el; +}; + +jasmine.HtmlReporterHelpers.getSpecStatus = function(child) { + var results = child.results(); + var status = results.passed() ? 'passed' : 'failed'; + if (results.skipped) { + status = 'skipped'; + } + + return status; +}; + +jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) { + var parentDiv = this.dom.summary; + var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite'; + var parent = child[parentSuite]; + + if (parent) { + if (typeof this.views.suites[parent.id] == 'undefined') { + this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views); + } + parentDiv = this.views.suites[parent.id].element; + } + + parentDiv.appendChild(childElement); +}; + + +jasmine.HtmlReporterHelpers.addHelpers = function(ctor) { + for(var fn in jasmine.HtmlReporterHelpers) { + ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn]; + } +}; + +jasmine.HtmlReporter.ReporterView = function(dom) { + this.startedAt = new Date(); + this.runningSpecCount = 0; + this.completeSpecCount = 0; + this.passedCount = 0; + this.failedCount = 0; + this.skippedCount = 0; + + this.createResultsMenu = function() { + this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'}, + this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'), + ' | ', + this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing')); + + this.summaryMenuItem.onclick = function() { + dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, ''); + }; + + this.detailsMenuItem.onclick = function() { + showDetails(); + }; + }; + + this.addSpecs = function(specs, specFilter) { + this.totalSpecCount = specs.length; + + this.views = { + specs: {}, + suites: {} + }; + + for (var i = 0; i < specs.length; i++) { + var spec = specs[i]; + this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views); + if (specFilter(spec)) { + this.runningSpecCount++; + } + } + }; + + this.specComplete = function(spec) { + this.completeSpecCount++; + + if (isUndefined(this.views.specs[spec.id])) { + this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom); + } + + var specView = this.views.specs[spec.id]; + + switch (specView.status()) { + case 'passed': + this.passedCount++; + break; + + case 'failed': + this.failedCount++; + break; + + case 'skipped': + this.skippedCount++; + break; + } + + specView.refresh(); + this.refresh(); + }; + + this.suiteComplete = function(suite) { + var suiteView = this.views.suites[suite.id]; + if (isUndefined(suiteView)) { + return; + } + suiteView.refresh(); + }; + + this.refresh = function() { + + if (isUndefined(this.resultsMenu)) { + this.createResultsMenu(); + } + + // currently running UI + if (isUndefined(this.runningAlert)) { + this.runningAlert = this.createDom('a', {href: "?", className: "runningAlert bar"}); + dom.alert.appendChild(this.runningAlert); + } + this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount); + + // skipped specs UI + if (isUndefined(this.skippedAlert)) { + this.skippedAlert = this.createDom('a', {href: "?", className: "skippedAlert bar"}); + } + + this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all"; + + if (this.skippedCount === 1 && isDefined(dom.alert)) { + dom.alert.appendChild(this.skippedAlert); + } + + // passing specs UI + if (isUndefined(this.passedAlert)) { + this.passedAlert = this.createDom('span', {href: "?", className: "passingAlert bar"}); + } + this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount); + + // failing specs UI + if (isUndefined(this.failedAlert)) { + this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"}); + } + this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount); + + if (this.failedCount === 1 && isDefined(dom.alert)) { + dom.alert.appendChild(this.failedAlert); + dom.alert.appendChild(this.resultsMenu); + } + + // summary info + this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount); + this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing"; + }; + + this.complete = function() { + dom.alert.removeChild(this.runningAlert); + + this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all"; + + if (this.failedCount === 0) { + dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount))); + } else { + showDetails(); + } + + dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s")); + }; + + return this; + + function showDetails() { + if (dom.reporter.className.search(/showDetails/) === -1) { + dom.reporter.className += " showDetails"; + } + } + + function isUndefined(obj) { + return typeof obj === 'undefined'; + } + + function isDefined(obj) { + return !isUndefined(obj); + } + + function specPluralizedFor(count) { + var str = count + " spec"; + if (count > 1) { + str += "s" + } + return str; + } + +}; + +jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView); + + +jasmine.HtmlReporter.SpecView = function(spec, dom, views) { + this.spec = spec; + this.dom = dom; + this.views = views; + + this.symbol = this.createDom('li', { className: 'pending' }); + this.dom.symbolSummary.appendChild(this.symbol); + + this.summary = this.createDom('div', { className: 'specSummary' }, + this.createDom('a', { + className: 'description', + href: '?spec=' + encodeURIComponent(this.spec.getFullName()), + title: this.spec.getFullName() + }, this.spec.description) + ); + + this.detail = this.createDom('div', { className: 'specDetail' }, + this.createDom('a', { + className: 'description', + href: '?spec=' + encodeURIComponent(this.spec.getFullName()), + title: this.spec.getFullName() + }, this.spec.getFullName()) + ); +}; + +jasmine.HtmlReporter.SpecView.prototype.status = function() { + return this.getSpecStatus(this.spec); +}; + +jasmine.HtmlReporter.SpecView.prototype.refresh = function() { + this.symbol.className = this.status(); + + switch (this.status()) { + case 'skipped': + break; + + case 'passed': + this.appendSummaryToSuiteDiv(); + break; + + case 'failed': + this.appendSummaryToSuiteDiv(); + this.appendFailureDetail(); + break; + } +}; + +jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() { + this.summary.className += ' ' + this.status(); + this.appendToSummary(this.spec, this.summary); +}; + +jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() { + this.detail.className += ' ' + this.status(); + + var resultItems = this.spec.results().getItems(); + var messagesDiv = this.createDom('div', { className: 'messages' }); + + for (var i = 0; i < resultItems.length; i++) { + var result = resultItems[i]; + + if (result.type == 'log') { + messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString())); + } else if (result.type == 'expect' && result.passed && !result.passed()) { + messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message)); + + if (result.trace.stack) { + messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack)); + } + } + } + + if (messagesDiv.childNodes.length > 0) { + this.detail.appendChild(messagesDiv); + this.dom.details.appendChild(this.detail); + } +}; + +jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.HtmlReporter.SuiteView = function(suite, dom, views) { + this.suite = suite; + this.dom = dom; + this.views = views; + + this.element = this.createDom('div', { className: 'suite' }, + this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(this.suite.getFullName()) }, this.suite.description) + ); + + this.appendToSummary(this.suite, this.element); +}; + +jasmine.HtmlReporter.SuiteView.prototype.status = function() { + return this.getSpecStatus(this.suite); +}; + +jasmine.HtmlReporter.SuiteView.prototype.refresh = function() { + this.element.className += " " + this.status(); +}; + +jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView); + +/* @deprecated Use jasmine.HtmlReporter instead + */ +jasmine.TrivialReporter = function(doc) { + this.document = doc || document; + this.suiteDivs = {}; + this.logRunningSpecs = false; +}; + +jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) { + var el = document.createElement(type); + + for (var i = 2; i < arguments.length; i++) { + var child = arguments[i]; + + if (typeof child === 'string') { + el.appendChild(document.createTextNode(child)); + } else { + if (child) { el.appendChild(child); } + } + } + + for (var attr in attrs) { + if (attr == "className") { + el[attr] = attrs[attr]; + } else { + el.setAttribute(attr, attrs[attr]); + } + } + + return el; +}; + +jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) { + var showPassed, showSkipped; + + this.outerDiv = this.createDom('div', { id: 'TrivialReporter', className: 'jasmine_reporter' }, + this.createDom('div', { className: 'banner' }, + this.createDom('div', { className: 'logo' }, + this.createDom('span', { className: 'title' }, "Jasmine"), + this.createDom('span', { className: 'version' }, runner.env.versionString())), + this.createDom('div', { className: 'options' }, + "Show ", + showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }), + this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "), + showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }), + this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped") + ) + ), + + this.runnerDiv = this.createDom('div', { className: 'runner running' }, + this.createDom('a', { className: 'run_spec', href: '?' }, "run all"), + this.runnerMessageSpan = this.createDom('span', {}, "Running..."), + this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, "")) + ); + + this.document.body.appendChild(this.outerDiv); + + var suites = runner.suites(); + for (var i = 0; i < suites.length; i++) { + var suite = suites[i]; + var suiteDiv = this.createDom('div', { className: 'suite' }, + this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"), + this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description)); + this.suiteDivs[suite.id] = suiteDiv; + var parentDiv = this.outerDiv; + if (suite.parentSuite) { + parentDiv = this.suiteDivs[suite.parentSuite.id]; + } + parentDiv.appendChild(suiteDiv); + } + + this.startedAt = new Date(); + + var self = this; + showPassed.onclick = function(evt) { + if (showPassed.checked) { + self.outerDiv.className += ' show-passed'; + } else { + self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, ''); + } + }; + + showSkipped.onclick = function(evt) { + if (showSkipped.checked) { + self.outerDiv.className += ' show-skipped'; + } else { + self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, ''); + } + }; +}; + +jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) { + var results = runner.results(); + var className = (results.failedCount > 0) ? "runner failed" : "runner passed"; + this.runnerDiv.setAttribute("class", className); + //do it twice for IE + this.runnerDiv.setAttribute("className", className); + var specs = runner.specs(); + var specCount = 0; + for (var i = 0; i < specs.length; i++) { + if (this.specFilter(specs[i])) { + specCount++; + } + } + var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s"); + message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"; + this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild); + + this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString())); +}; + +jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) { + var results = suite.results(); + var status = results.passed() ? 'passed' : 'failed'; + if (results.totalCount === 0) { // todo: change this to check results.skipped + status = 'skipped'; + } + this.suiteDivs[suite.id].className += " " + status; +}; + +jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) { + if (this.logRunningSpecs) { + this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...'); + } +}; + +jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) { + var results = spec.results(); + var status = results.passed() ? 'passed' : 'failed'; + if (results.skipped) { + status = 'skipped'; + } + var specDiv = this.createDom('div', { className: 'spec ' + status }, + this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"), + this.createDom('a', { + className: 'description', + href: '?spec=' + encodeURIComponent(spec.getFullName()), + title: spec.getFullName() + }, spec.description)); + + + var resultItems = results.getItems(); + var messagesDiv = this.createDom('div', { className: 'messages' }); + for (var i = 0; i < resultItems.length; i++) { + var result = resultItems[i]; + + if (result.type == 'log') { + messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString())); + } else if (result.type == 'expect' && result.passed && !result.passed()) { + messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message)); + + if (result.trace.stack) { + messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack)); + } + } + } + + if (messagesDiv.childNodes.length > 0) { + specDiv.appendChild(messagesDiv); + } + + this.suiteDivs[spec.suite.id].appendChild(specDiv); +}; + +jasmine.TrivialReporter.prototype.log = function() { + var console = jasmine.getGlobal().console; + if (console && console.log) { + if (console.log.apply) { + console.log.apply(console, arguments); + } else { + console.log(arguments); // ie fix: console.log.apply doesn't exist on ie + } + } +}; + +jasmine.TrivialReporter.prototype.getLocation = function() { + return this.document.location; +}; + +jasmine.TrivialReporter.prototype.specFilter = function(spec) { + var paramMap = {}; + var params = this.getLocation().search.substring(1).split('&'); + for (var i = 0; i < params.length; i++) { + var p = params[i].split('='); + paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); + } + + if (!paramMap.spec) { + return true; + } + return spec.getFullName().indexOf(paramMap.spec) === 0; +}; diff --git a/addons/web/static/lib/pdfjs/external/jasmine/jasmine.css b/addons/web/static/lib/pdfjs/external/jasmine/jasmine.css new file mode 100644 index 00000000000..826e575310c --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/jasmine/jasmine.css @@ -0,0 +1,81 @@ +body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; } + +#HTMLReporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; } +#HTMLReporter a { text-decoration: none; } +#HTMLReporter a:hover { text-decoration: underline; } +#HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 { margin: 0; line-height: 14px; } +#HTMLReporter .banner, #HTMLReporter .symbolSummary, #HTMLReporter .summary, #HTMLReporter .resultMessage, #HTMLReporter .specDetail .description, #HTMLReporter .alert .bar, #HTMLReporter .stackTrace { padding-left: 9px; padding-right: 9px; } +#HTMLReporter #jasmine_content { position: fixed; right: 100%; } +#HTMLReporter .version { color: #aaaaaa; } +#HTMLReporter .banner { margin-top: 14px; } +#HTMLReporter .duration { color: #aaaaaa; float: right; } +#HTMLReporter .symbolSummary { overflow: hidden; *zoom: 1; margin: 14px 0; } +#HTMLReporter .symbolSummary li { display: block; float: left; height: 7px; width: 14px; margin-bottom: 7px; font-size: 16px; } +#HTMLReporter .symbolSummary li.passed { font-size: 14px; } +#HTMLReporter .symbolSummary li.passed:before { color: #5e7d00; content: "\02022"; } +#HTMLReporter .symbolSummary li.failed { line-height: 9px; } +#HTMLReporter .symbolSummary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; } +#HTMLReporter .symbolSummary li.skipped { font-size: 14px; } +#HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; } +#HTMLReporter .symbolSummary li.pending { line-height: 11px; } +#HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; } +#HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; } +#HTMLReporter .runningAlert { background-color: #666666; } +#HTMLReporter .skippedAlert { background-color: #aaaaaa; } +#HTMLReporter .skippedAlert:first-child { background-color: #333333; } +#HTMLReporter .skippedAlert:hover { text-decoration: none; color: white; text-decoration: underline; } +#HTMLReporter .passingAlert { background-color: #a6b779; } +#HTMLReporter .passingAlert:first-child { background-color: #5e7d00; } +#HTMLReporter .failingAlert { background-color: #cf867e; } +#HTMLReporter .failingAlert:first-child { background-color: #b03911; } +#HTMLReporter .results { margin-top: 14px; } +#HTMLReporter #details { display: none; } +#HTMLReporter .resultsMenu, #HTMLReporter .resultsMenu a { background-color: #fff; color: #333333; } +#HTMLReporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; } +#HTMLReporter.showDetails .summaryMenuItem:hover { text-decoration: underline; } +#HTMLReporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; } +#HTMLReporter.showDetails .summary { display: none; } +#HTMLReporter.showDetails #details { display: block; } +#HTMLReporter .summaryMenuItem { font-weight: bold; text-decoration: underline; } +#HTMLReporter .summary { margin-top: 14px; } +#HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary { margin-left: 14px; } +#HTMLReporter .summary .specSummary.passed a { color: #5e7d00; } +#HTMLReporter .summary .specSummary.failed a { color: #b03911; } +#HTMLReporter .description + .suite { margin-top: 0; } +#HTMLReporter .suite { margin-top: 14px; } +#HTMLReporter .suite a { color: #333333; } +#HTMLReporter #details .specDetail { margin-bottom: 28px; } +#HTMLReporter #details .specDetail .description { display: block; color: white; background-color: #b03911; } +#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; } +#HTMLReporter .resultMessage span.result { display: block; } +#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; } + +#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ } +#TrivialReporter a:visited, #TrivialReporter a { color: #303; } +#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; } +#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; } +#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; } +#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; } +#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; } +#TrivialReporter .runner.running { background-color: yellow; } +#TrivialReporter .options { text-align: right; font-size: .8em; } +#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; } +#TrivialReporter .suite .suite { margin: 5px; } +#TrivialReporter .suite.passed { background-color: #dfd; } +#TrivialReporter .suite.failed { background-color: #fdd; } +#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; } +#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; } +#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; } +#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; } +#TrivialReporter .spec.skipped { background-color: #bbb; } +#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; } +#TrivialReporter .passed { background-color: #cfc; display: none; } +#TrivialReporter .failed { background-color: #fbb; } +#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; } +#TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; } +#TrivialReporter .resultMessage .mismatch { color: black; } +#TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; } +#TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; } +#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; } +#TrivialReporter #jasmine_content { position: fixed; right: 100%; } +#TrivialReporter .runner { border: 1px solid gray; display: block; margin: 5px 0; padding: 2px 0 2px 10px; } diff --git a/addons/web/static/lib/pdfjs/external/jasmine/jasmine.js b/addons/web/static/lib/pdfjs/external/jasmine/jasmine.js new file mode 100644 index 00000000000..adf9859b4d4 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/jasmine/jasmine.js @@ -0,0 +1,2469 @@ +var isCommonJS = typeof window == "undefined"; + +/** + * Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework. + * + * @namespace + */ +var jasmine = {}; +if (isCommonJS) exports.jasmine = jasmine; +/** + * @private + */ +jasmine.unimplementedMethod_ = function() { + throw new Error("unimplemented method"); +}; + +/** + * Use <code>jasmine.undefined</code> instead of <code>undefined</code>, since <code>undefined</code> is just + * a plain old variable and may be redefined by somebody else. + * + * @private + */ +jasmine.undefined = jasmine.___undefined___; + +/** + * Show diagnostic messages in the console if set to true + * + */ +jasmine.VERBOSE = false; + +/** + * Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). Small values here may result in slow test running. Zero means no updates until all tests have completed. + * + */ +jasmine.DEFAULT_UPDATE_INTERVAL = 250; + +/** + * Default timeout interval in milliseconds for waitsFor() blocks. + */ +jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000; + +jasmine.getGlobal = function() { + function getGlobal() { + return this; + } + + return getGlobal(); +}; + +/** + * Allows for bound functions to be compared. Internal use only. + * + * @ignore + * @private + * @param base {Object} bound 'this' for the function + * @param name {Function} function to find + */ +jasmine.bindOriginal_ = function(base, name) { + var original = base[name]; + if (original.apply) { + return function() { + return original.apply(base, arguments); + }; + } else { + // IE support + return jasmine.getGlobal()[name]; + } +}; + +jasmine.setTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'setTimeout'); +jasmine.clearTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearTimeout'); +jasmine.setInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'setInterval'); +jasmine.clearInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearInterval'); + +jasmine.MessageResult = function(values) { + this.type = 'log'; + this.values = values; + this.trace = new Error(); // todo: test better +}; + +jasmine.MessageResult.prototype.toString = function() { + var text = ""; + for (var i = 0; i < this.values.length; i++) { + if (i > 0) text += " "; + if (jasmine.isString_(this.values[i])) { + text += this.values[i]; + } else { + text += jasmine.pp(this.values[i]); + } + } + return text; +}; + +jasmine.ExpectationResult = function(params) { + this.type = 'expect'; + this.matcherName = params.matcherName; + this.passed_ = params.passed; + this.expected = params.expected; + this.actual = params.actual; + this.message = this.passed_ ? 'Passed.' : params.message; + + var trace = (params.trace || new Error(this.message)); + this.trace = this.passed_ ? '' : trace; +}; + +jasmine.ExpectationResult.prototype.toString = function () { + return this.message; +}; + +jasmine.ExpectationResult.prototype.passed = function () { + return this.passed_; +}; + +/** + * Getter for the Jasmine environment. Ensures one gets created + */ +jasmine.getEnv = function() { + var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env(); + return env; +}; + +/** + * @ignore + * @private + * @param value + * @returns {Boolean} + */ +jasmine.isArray_ = function(value) { + return jasmine.isA_("Array", value); +}; + +/** + * @ignore + * @private + * @param value + * @returns {Boolean} + */ +jasmine.isString_ = function(value) { + return jasmine.isA_("String", value); +}; + +/** + * @ignore + * @private + * @param value + * @returns {Boolean} + */ +jasmine.isNumber_ = function(value) { + return jasmine.isA_("Number", value); +}; + +/** + * @ignore + * @private + * @param {String} typeName + * @param value + * @returns {Boolean} + */ +jasmine.isA_ = function(typeName, value) { + return Object.prototype.toString.apply(value) === '[object ' + typeName + ']'; +}; + +/** + * Pretty printer for expecations. Takes any object and turns it into a human-readable string. + * + * @param value {Object} an object to be outputted + * @returns {String} + */ +jasmine.pp = function(value) { + var stringPrettyPrinter = new jasmine.StringPrettyPrinter(); + stringPrettyPrinter.format(value); + return stringPrettyPrinter.string; +}; + +/** + * Returns true if the object is a DOM Node. + * + * @param {Object} obj object to check + * @returns {Boolean} + */ +jasmine.isDomNode = function(obj) { + return obj.nodeType > 0; +}; + +/** + * Returns a matchable 'generic' object of the class type. For use in expecations of type when values don't matter. + * + * @example + * // don't care about which function is passed in, as long as it's a function + * expect(mySpy).toHaveBeenCalledWith(jasmine.any(Function)); + * + * @param {Class} clazz + * @returns matchable object of the type clazz + */ +jasmine.any = function(clazz) { + return new jasmine.Matchers.Any(clazz); +}; + +/** + * Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks. + * + * Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine + * expectation syntax. Spies can be checked if they were called or not and what the calling params were. + * + * A Spy has the following fields: wasCalled, callCount, mostRecentCall, and argsForCall (see docs). + * + * Spies are torn down at the end of every spec. + * + * Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj. + * + * @example + * // a stub + * var myStub = jasmine.createSpy('myStub'); // can be used anywhere + * + * // spy example + * var foo = { + * not: function(bool) { return !bool; } + * } + * + * // actual foo.not will not be called, execution stops + * spyOn(foo, 'not'); + + // foo.not spied upon, execution will continue to implementation + * spyOn(foo, 'not').andCallThrough(); + * + * // fake example + * var foo = { + * not: function(bool) { return !bool; } + * } + * + * // foo.not(val) will return val + * spyOn(foo, 'not').andCallFake(function(value) {return value;}); + * + * // mock example + * foo.not(7 == 7); + * expect(foo.not).toHaveBeenCalled(); + * expect(foo.not).toHaveBeenCalledWith(true); + * + * @constructor + * @see spyOn, jasmine.createSpy, jasmine.createSpyObj + * @param {String} name + */ +jasmine.Spy = function(name) { + /** + * The name of the spy, if provided. + */ + this.identity = name || 'unknown'; + /** + * Is this Object a spy? + */ + this.isSpy = true; + /** + * The actual function this spy stubs. + */ + this.plan = function() { + }; + /** + * Tracking of the most recent call to the spy. + * @example + * var mySpy = jasmine.createSpy('foo'); + * mySpy(1, 2); + * mySpy.mostRecentCall.args = [1, 2]; + */ + this.mostRecentCall = {}; + + /** + * Holds arguments for each call to the spy, indexed by call count + * @example + * var mySpy = jasmine.createSpy('foo'); + * mySpy(1, 2); + * mySpy(7, 8); + * mySpy.mostRecentCall.args = [7, 8]; + * mySpy.argsForCall[0] = [1, 2]; + * mySpy.argsForCall[1] = [7, 8]; + */ + this.argsForCall = []; + this.calls = []; +}; + +/** + * Tells a spy to call through to the actual implemenatation. + * + * @example + * var foo = { + * bar: function() { // do some stuff } + * } + * + * // defining a spy on an existing property: foo.bar + * spyOn(foo, 'bar').andCallThrough(); + */ +jasmine.Spy.prototype.andCallThrough = function() { + this.plan = this.originalValue; + return this; +}; + +/** + * For setting the return value of a spy. + * + * @example + * // defining a spy from scratch: foo() returns 'baz' + * var foo = jasmine.createSpy('spy on foo').andReturn('baz'); + * + * // defining a spy on an existing property: foo.bar() returns 'baz' + * spyOn(foo, 'bar').andReturn('baz'); + * + * @param {Object} value + */ +jasmine.Spy.prototype.andReturn = function(value) { + this.plan = function() { + return value; + }; + return this; +}; + +/** + * For throwing an exception when a spy is called. + * + * @example + * // defining a spy from scratch: foo() throws an exception w/ message 'ouch' + * var foo = jasmine.createSpy('spy on foo').andThrow('baz'); + * + * // defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch' + * spyOn(foo, 'bar').andThrow('baz'); + * + * @param {String} exceptionMsg + */ +jasmine.Spy.prototype.andThrow = function(exceptionMsg) { + this.plan = function() { + throw exceptionMsg; + }; + return this; +}; + +/** + * Calls an alternate implementation when a spy is called. + * + * @example + * var baz = function() { + * // do some stuff, return something + * } + * // defining a spy from scratch: foo() calls the function baz + * var foo = jasmine.createSpy('spy on foo').andCall(baz); + * + * // defining a spy on an existing property: foo.bar() calls an anonymnous function + * spyOn(foo, 'bar').andCall(function() { return 'baz';} ); + * + * @param {Function} fakeFunc + */ +jasmine.Spy.prototype.andCallFake = function(fakeFunc) { + this.plan = fakeFunc; + return this; +}; + +/** + * Resets all of a spy's the tracking variables so that it can be used again. + * + * @example + * spyOn(foo, 'bar'); + * + * foo.bar(); + * + * expect(foo.bar.callCount).toEqual(1); + * + * foo.bar.reset(); + * + * expect(foo.bar.callCount).toEqual(0); + */ +jasmine.Spy.prototype.reset = function() { + this.wasCalled = false; + this.callCount = 0; + this.argsForCall = []; + this.calls = []; + this.mostRecentCall = {}; +}; + +jasmine.createSpy = function(name) { + + var spyObj = function() { + spyObj.wasCalled = true; + spyObj.callCount++; + var args = jasmine.util.argsToArray(arguments); + spyObj.mostRecentCall.object = this; + spyObj.mostRecentCall.args = args; + spyObj.argsForCall.push(args); + spyObj.calls.push({object: this, args: args}); + return spyObj.plan.apply(this, arguments); + }; + + var spy = new jasmine.Spy(name); + + for (var prop in spy) { + spyObj[prop] = spy[prop]; + } + + spyObj.reset(); + + return spyObj; +}; + +/** + * Determines whether an object is a spy. + * + * @param {jasmine.Spy|Object} putativeSpy + * @returns {Boolean} + */ +jasmine.isSpy = function(putativeSpy) { + return putativeSpy && putativeSpy.isSpy; +}; + +/** + * Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something + * large in one call. + * + * @param {String} baseName name of spy class + * @param {Array} methodNames array of names of methods to make spies + */ +jasmine.createSpyObj = function(baseName, methodNames) { + if (!jasmine.isArray_(methodNames) || methodNames.length === 0) { + throw new Error('createSpyObj requires a non-empty array of method names to create spies for'); + } + var obj = {}; + for (var i = 0; i < methodNames.length; i++) { + obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]); + } + return obj; +}; + +/** + * All parameters are pretty-printed and concatenated together, then written to the current spec's output. + * + * Be careful not to leave calls to <code>jasmine.log</code> in production code. + */ +jasmine.log = function() { + var spec = jasmine.getEnv().currentSpec; + spec.log.apply(spec, arguments); +}; + +/** + * Function that installs a spy on an existing object's method name. Used within a Spec to create a spy. + * + * @example + * // spy example + * var foo = { + * not: function(bool) { return !bool; } + * } + * spyOn(foo, 'not'); // actual foo.not will not be called, execution stops + * + * @see jasmine.createSpy + * @param obj + * @param methodName + * @returns a Jasmine spy that can be chained with all spy methods + */ +var spyOn = function(obj, methodName) { + return jasmine.getEnv().currentSpec.spyOn(obj, methodName); +}; +if (isCommonJS) exports.spyOn = spyOn; + +/** + * Creates a Jasmine spec that will be added to the current suite. + * + * @example + * it('should be true', function() { + * expect(true).toEqual(true); + * }); + * + * @param {String} desc description of this specification + * @param {Function} func defines the preconditions and expectations of the spec + */ +var it = function(desc, func) { + return jasmine.getEnv().it(desc, func); +}; +if (isCommonJS) exports.it = it; + +/** + * Creates a <em>disabled</em> Jasmine spec. + * + * A convenience method that allows existing specs to be disabled temporarily during development. + * + * @param {String} desc description of this specification + * @param {Function} func defines the preconditions and expectations of the spec + */ +var xit = function(desc, func) { + return jasmine.getEnv().xit(desc, func); +}; +if (isCommonJS) exports.xit = xit; + +/** + * Starts a chain for a Jasmine expectation. + * + * It is passed an Object that is the actual value and should chain to one of the many + * jasmine.Matchers functions. + * + * @param {Object} actual Actual value to test against and expected value + */ +var expect = function(actual) { + return jasmine.getEnv().currentSpec.expect(actual); +}; +if (isCommonJS) exports.expect = expect; + +/** + * Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs. + * + * @param {Function} func Function that defines part of a jasmine spec. + */ +var runs = function(func) { + jasmine.getEnv().currentSpec.runs(func); +}; +if (isCommonJS) exports.runs = runs; + +/** + * Waits a fixed time period before moving to the next block. + * + * @deprecated Use waitsFor() instead + * @param {Number} timeout milliseconds to wait + */ +var waits = function(timeout) { + jasmine.getEnv().currentSpec.waits(timeout); +}; +if (isCommonJS) exports.waits = waits; + +/** + * Waits for the latchFunction to return true before proceeding to the next block. + * + * @param {Function} latchFunction + * @param {String} optional_timeoutMessage + * @param {Number} optional_timeout + */ +var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) { + jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments); +}; +if (isCommonJS) exports.waitsFor = waitsFor; + +/** + * A function that is called before each spec in a suite. + * + * Used for spec setup, including validating assumptions. + * + * @param {Function} beforeEachFunction + */ +var beforeEach = function(beforeEachFunction) { + jasmine.getEnv().beforeEach(beforeEachFunction); +}; +if (isCommonJS) exports.beforeEach = beforeEach; + +/** + * A function that is called after each spec in a suite. + * + * Used for restoring any state that is hijacked during spec execution. + * + * @param {Function} afterEachFunction + */ +var afterEach = function(afterEachFunction) { + jasmine.getEnv().afterEach(afterEachFunction); +}; +if (isCommonJS) exports.afterEach = afterEach; + +/** + * Defines a suite of specifications. + * + * Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared + * are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization + * of setup in some tests. + * + * @param {String} description A string, usually the class under test. + * @param {Function} specDefinitions function that defines several specs. + */ +var describe = function(description, specDefinitions) { + return jasmine.getEnv().describe(description, specDefinitions); +}; +if (isCommonJS) exports.describe = describe; + +/** + * Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development. + * + * @param {String} description A string, usually the class under test. + * @param {Function} specDefinitions function that defines several specs. + */ +var xdescribe = function(description, specDefinitions) { + return jasmine.getEnv().xdescribe(description, specDefinitions); +}; +if (isCommonJS) exports.xdescribe = xdescribe; + + +// Provide the XMLHttpRequest class for IE 5.x-6.x: +jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() { + function tryIt(f) { + try { + return f(); + } catch(e) { + } + return null; + } + + var xhr = tryIt(function() { + return new ActiveXObject("Msxml2.XMLHTTP.6.0"); + }) || + tryIt(function() { + return new ActiveXObject("Msxml2.XMLHTTP.3.0"); + }) || + tryIt(function() { + return new ActiveXObject("Msxml2.XMLHTTP"); + }) || + tryIt(function() { + return new ActiveXObject("Microsoft.XMLHTTP"); + }); + + if (!xhr) throw new Error("This browser does not support XMLHttpRequest."); + + return xhr; +} : XMLHttpRequest; +/** + * @namespace + */ +jasmine.util = {}; + +/** + * Declare that a child class inherit it's prototype from the parent class. + * + * @private + * @param {Function} childClass + * @param {Function} parentClass + */ +jasmine.util.inherit = function(childClass, parentClass) { + /** + * @private + */ + var subclass = function() { + }; + subclass.prototype = parentClass.prototype; + childClass.prototype = new subclass(); +}; + +jasmine.util.formatException = function(e) { + var lineNumber; + if (e.line) { + lineNumber = e.line; + } + else if (e.lineNumber) { + lineNumber = e.lineNumber; + } + + var file; + + if (e.sourceURL) { + file = e.sourceURL; + } + else if (e.fileName) { + file = e.fileName; + } + + var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString(); + + if (file && lineNumber) { + message += ' in ' + file + ' (line ' + lineNumber + ')'; + } + + return message; +}; + +jasmine.util.htmlEscape = function(str) { + if (!str) return str; + return str.replace(/&/g, '&') + .replace(/</g, '<') + .replace(/>/g, '>'); +}; + +jasmine.util.argsToArray = function(args) { + var arrayOfArgs = []; + for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]); + return arrayOfArgs; +}; + +jasmine.util.extend = function(destination, source) { + for (var property in source) destination[property] = source[property]; + return destination; +}; + +/** + * Environment for Jasmine + * + * @constructor + */ +jasmine.Env = function() { + this.currentSpec = null; + this.currentSuite = null; + this.currentRunner_ = new jasmine.Runner(this); + + this.reporter = new jasmine.MultiReporter(); + + this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL; + this.defaultTimeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL; + this.lastUpdate = 0; + this.specFilter = function() { + return true; + }; + + this.nextSpecId_ = 0; + this.nextSuiteId_ = 0; + this.equalityTesters_ = []; + + // wrap matchers + this.matchersClass = function() { + jasmine.Matchers.apply(this, arguments); + }; + jasmine.util.inherit(this.matchersClass, jasmine.Matchers); + + jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass); +}; + + +jasmine.Env.prototype.setTimeout = jasmine.setTimeout; +jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout; +jasmine.Env.prototype.setInterval = jasmine.setInterval; +jasmine.Env.prototype.clearInterval = jasmine.clearInterval; + +/** + * @returns an object containing jasmine version build info, if set. + */ +jasmine.Env.prototype.version = function () { + if (jasmine.version_) { + return jasmine.version_; + } else { + throw new Error('Version not set'); + } +}; + +/** + * @returns string containing jasmine version build info, if set. + */ +jasmine.Env.prototype.versionString = function() { + if (!jasmine.version_) { + return "version unknown"; + } + + var version = this.version(); + var versionString = version.major + "." + version.minor + "." + version.build; + if (version.release_candidate) { + versionString += ".rc" + version.release_candidate; + } + versionString += " revision " + version.revision; + return versionString; +}; + +/** + * @returns a sequential integer starting at 0 + */ +jasmine.Env.prototype.nextSpecId = function () { + return this.nextSpecId_++; +}; + +/** + * @returns a sequential integer starting at 0 + */ +jasmine.Env.prototype.nextSuiteId = function () { + return this.nextSuiteId_++; +}; + +/** + * Register a reporter to receive status updates from Jasmine. + * @param {jasmine.Reporter} reporter An object which will receive status updates. + */ +jasmine.Env.prototype.addReporter = function(reporter) { + this.reporter.addReporter(reporter); +}; + +jasmine.Env.prototype.execute = function() { + this.currentRunner_.execute(); +}; + +jasmine.Env.prototype.describe = function(description, specDefinitions) { + var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite); + + var parentSuite = this.currentSuite; + if (parentSuite) { + parentSuite.add(suite); + } else { + this.currentRunner_.add(suite); + } + + this.currentSuite = suite; + + var declarationError = null; + try { + specDefinitions.call(suite); + } catch(e) { + declarationError = e; + } + + if (declarationError) { + this.it("encountered a declaration exception", function() { + throw declarationError; + }); + } + + this.currentSuite = parentSuite; + + return suite; +}; + +jasmine.Env.prototype.beforeEach = function(beforeEachFunction) { + if (this.currentSuite) { + this.currentSuite.beforeEach(beforeEachFunction); + } else { + this.currentRunner_.beforeEach(beforeEachFunction); + } +}; + +jasmine.Env.prototype.currentRunner = function () { + return this.currentRunner_; +}; + +jasmine.Env.prototype.afterEach = function(afterEachFunction) { + if (this.currentSuite) { + this.currentSuite.afterEach(afterEachFunction); + } else { + this.currentRunner_.afterEach(afterEachFunction); + } + +}; + +jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) { + return { + execute: function() { + } + }; +}; + +jasmine.Env.prototype.it = function(description, func) { + var spec = new jasmine.Spec(this, this.currentSuite, description); + this.currentSuite.add(spec); + this.currentSpec = spec; + + if (func) { + spec.runs(func); + } + + return spec; +}; + +jasmine.Env.prototype.xit = function(desc, func) { + return { + id: this.nextSpecId(), + runs: function() { + } + }; +}; + +jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) { + if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) { + return true; + } + + a.__Jasmine_been_here_before__ = b; + b.__Jasmine_been_here_before__ = a; + + var hasKey = function(obj, keyName) { + return obj !== null && obj[keyName] !== jasmine.undefined; + }; + + for (var property in b) { + if (!hasKey(a, property) && hasKey(b, property)) { + mismatchKeys.push("expected has key '" + property + "', but missing from actual."); + } + } + for (property in a) { + if (!hasKey(b, property) && hasKey(a, property)) { + mismatchKeys.push("expected missing key '" + property + "', but present in actual."); + } + } + for (property in b) { + if (property == '__Jasmine_been_here_before__') continue; + if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) { + mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual."); + } + } + + if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) { + mismatchValues.push("arrays were not the same length"); + } + + delete a.__Jasmine_been_here_before__; + delete b.__Jasmine_been_here_before__; + return (mismatchKeys.length === 0 && mismatchValues.length === 0); +}; + +jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) { + mismatchKeys = mismatchKeys || []; + mismatchValues = mismatchValues || []; + + for (var i = 0; i < this.equalityTesters_.length; i++) { + var equalityTester = this.equalityTesters_[i]; + var result = equalityTester(a, b, this, mismatchKeys, mismatchValues); + if (result !== jasmine.undefined) return result; + } + + if (a === b) return true; + + if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) { + return (a == jasmine.undefined && b == jasmine.undefined); + } + + if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) { + return a === b; + } + + if (a instanceof Date && b instanceof Date) { + return a.getTime() == b.getTime(); + } + + if (a instanceof jasmine.Matchers.Any) { + return a.matches(b); + } + + if (b instanceof jasmine.Matchers.Any) { + return b.matches(a); + } + + if (jasmine.isString_(a) && jasmine.isString_(b)) { + return (a == b); + } + + if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) { + return (a == b); + } + + if (typeof a === "object" && typeof b === "object") { + return this.compareObjects_(a, b, mismatchKeys, mismatchValues); + } + + //Straight check + return (a === b); +}; + +jasmine.Env.prototype.contains_ = function(haystack, needle) { + if (jasmine.isArray_(haystack)) { + for (var i = 0; i < haystack.length; i++) { + if (this.equals_(haystack[i], needle)) return true; + } + return false; + } + return haystack.indexOf(needle) >= 0; +}; + +jasmine.Env.prototype.addEqualityTester = function(equalityTester) { + this.equalityTesters_.push(equalityTester); +}; +/** No-op base class for Jasmine reporters. + * + * @constructor + */ +jasmine.Reporter = function() { +}; + +//noinspection JSUnusedLocalSymbols +jasmine.Reporter.prototype.reportRunnerStarting = function(runner) { +}; + +//noinspection JSUnusedLocalSymbols +jasmine.Reporter.prototype.reportRunnerResults = function(runner) { +}; + +//noinspection JSUnusedLocalSymbols +jasmine.Reporter.prototype.reportSuiteResults = function(suite) { +}; + +//noinspection JSUnusedLocalSymbols +jasmine.Reporter.prototype.reportSpecStarting = function(spec) { +}; + +//noinspection JSUnusedLocalSymbols +jasmine.Reporter.prototype.reportSpecResults = function(spec) { +}; + +//noinspection JSUnusedLocalSymbols +jasmine.Reporter.prototype.log = function(str) { +}; + +/** + * Blocks are functions with executable code that make up a spec. + * + * @constructor + * @param {jasmine.Env} env + * @param {Function} func + * @param {jasmine.Spec} spec + */ +jasmine.Block = function(env, func, spec) { + this.env = env; + this.func = func; + this.spec = spec; +}; + +jasmine.Block.prototype.execute = function(onComplete) { + try { + this.func.apply(this.spec); + } catch (e) { + this.spec.fail(e); + } + onComplete(); +}; +/** JavaScript API reporter. + * + * @constructor + */ +jasmine.JsApiReporter = function() { + this.started = false; + this.finished = false; + this.suites_ = []; + this.results_ = {}; +}; + +jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) { + this.started = true; + var suites = runner.topLevelSuites(); + for (var i = 0; i < suites.length; i++) { + var suite = suites[i]; + this.suites_.push(this.summarize_(suite)); + } +}; + +jasmine.JsApiReporter.prototype.suites = function() { + return this.suites_; +}; + +jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) { + var isSuite = suiteOrSpec instanceof jasmine.Suite; + var summary = { + id: suiteOrSpec.id, + name: suiteOrSpec.description, + type: isSuite ? 'suite' : 'spec', + children: [] + }; + + if (isSuite) { + var children = suiteOrSpec.children(); + for (var i = 0; i < children.length; i++) { + summary.children.push(this.summarize_(children[i])); + } + } + return summary; +}; + +jasmine.JsApiReporter.prototype.results = function() { + return this.results_; +}; + +jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) { + return this.results_[specId]; +}; + +//noinspection JSUnusedLocalSymbols +jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) { + this.finished = true; +}; + +//noinspection JSUnusedLocalSymbols +jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) { +}; + +//noinspection JSUnusedLocalSymbols +jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) { + this.results_[spec.id] = { + messages: spec.results().getItems(), + result: spec.results().failedCount > 0 ? "failed" : "passed" + }; +}; + +//noinspection JSUnusedLocalSymbols +jasmine.JsApiReporter.prototype.log = function(str) { +}; + +jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){ + var results = {}; + for (var i = 0; i < specIds.length; i++) { + var specId = specIds[i]; + results[specId] = this.summarizeResult_(this.results_[specId]); + } + return results; +}; + +jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){ + var summaryMessages = []; + var messagesLength = result.messages.length; + for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) { + var resultMessage = result.messages[messageIndex]; + summaryMessages.push({ + text: resultMessage.type == 'log' ? resultMessage.toString() : jasmine.undefined, + passed: resultMessage.passed ? resultMessage.passed() : true, + type: resultMessage.type, + message: resultMessage.message, + trace: { + stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined + } + }); + } + + return { + result : result.result, + messages : summaryMessages + }; +}; + +/** + * @constructor + * @param {jasmine.Env} env + * @param actual + * @param {jasmine.Spec} spec + */ +jasmine.Matchers = function(env, actual, spec, opt_isNot) { + this.env = env; + this.actual = actual; + this.spec = spec; + this.isNot = opt_isNot || false; + this.reportWasCalled_ = false; +}; + +// todo: @deprecated as of Jasmine 0.11, remove soon [xw] +jasmine.Matchers.pp = function(str) { + throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!"); +}; + +// todo: @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. [xw] +jasmine.Matchers.prototype.report = function(result, failing_message, details) { + throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs"); +}; + +jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) { + for (var methodName in prototype) { + if (methodName == 'report') continue; + var orig = prototype[methodName]; + matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig); + } +}; + +jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) { + return function() { + var matcherArgs = jasmine.util.argsToArray(arguments); + var result = matcherFunction.apply(this, arguments); + + if (this.isNot) { + result = !result; + } + + if (this.reportWasCalled_) return result; + + var message; + if (!result) { + if (this.message) { + message = this.message.apply(this, arguments); + if (jasmine.isArray_(message)) { + message = message[this.isNot ? 1 : 0]; + } + } else { + var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); }); + message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate; + if (matcherArgs.length > 0) { + for (var i = 0; i < matcherArgs.length; i++) { + if (i > 0) message += ","; + message += " " + jasmine.pp(matcherArgs[i]); + } + } + message += "."; + } + } + var expectationResult = new jasmine.ExpectationResult({ + matcherName: matcherName, + passed: result, + expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0], + actual: this.actual, + message: message + }); + this.spec.addMatcherResult(expectationResult); + return jasmine.undefined; + }; +}; + + + + +/** + * toBe: compares the actual to the expected using === + * @param expected + */ +jasmine.Matchers.prototype.toBe = function(expected) { + return this.actual === expected; +}; + +/** + * toNotBe: compares the actual to the expected using !== + * @param expected + * @deprecated as of 1.0. Use not.toBe() instead. + */ +jasmine.Matchers.prototype.toNotBe = function(expected) { + return this.actual !== expected; +}; + +/** + * toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc. + * + * @param expected + */ +jasmine.Matchers.prototype.toEqual = function(expected) { + return this.env.equals_(this.actual, expected); +}; + +/** + * toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual + * @param expected + * @deprecated as of 1.0. Use not.toNotEqual() instead. + */ +jasmine.Matchers.prototype.toNotEqual = function(expected) { + return !this.env.equals_(this.actual, expected); +}; + +/** + * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes + * a pattern or a String. + * + * @param expected + */ +jasmine.Matchers.prototype.toMatch = function(expected) { + return new RegExp(expected).test(this.actual); +}; + +/** + * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch + * @param expected + * @deprecated as of 1.0. Use not.toMatch() instead. + */ +jasmine.Matchers.prototype.toNotMatch = function(expected) { + return !(new RegExp(expected).test(this.actual)); +}; + +/** + * Matcher that compares the actual to jasmine.undefined. + */ +jasmine.Matchers.prototype.toBeDefined = function() { + return (this.actual !== jasmine.undefined); +}; + +/** + * Matcher that compares the actual to jasmine.undefined. + */ +jasmine.Matchers.prototype.toBeUndefined = function() { + return (this.actual === jasmine.undefined); +}; + +/** + * Matcher that compares the actual to null. + */ +jasmine.Matchers.prototype.toBeNull = function() { + return (this.actual === null); +}; + +/** + * Matcher that boolean not-nots the actual. + */ +jasmine.Matchers.prototype.toBeTruthy = function() { + return !!this.actual; +}; + + +/** + * Matcher that boolean nots the actual. + */ +jasmine.Matchers.prototype.toBeFalsy = function() { + return !this.actual; +}; + + +/** + * Matcher that checks to see if the actual, a Jasmine spy, was called. + */ +jasmine.Matchers.prototype.toHaveBeenCalled = function() { + if (arguments.length > 0) { + throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith'); + } + + if (!jasmine.isSpy(this.actual)) { + throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); + } + + this.message = function() { + return [ + "Expected spy " + this.actual.identity + " to have been called.", + "Expected spy " + this.actual.identity + " not to have been called." + ]; + }; + + return this.actual.wasCalled; +}; + +/** @deprecated Use expect(xxx).toHaveBeenCalled() instead */ +jasmine.Matchers.prototype.wasCalled = jasmine.Matchers.prototype.toHaveBeenCalled; + +/** + * Matcher that checks to see if the actual, a Jasmine spy, was not called. + * + * @deprecated Use expect(xxx).not.toHaveBeenCalled() instead + */ +jasmine.Matchers.prototype.wasNotCalled = function() { + if (arguments.length > 0) { + throw new Error('wasNotCalled does not take arguments'); + } + + if (!jasmine.isSpy(this.actual)) { + throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); + } + + this.message = function() { + return [ + "Expected spy " + this.actual.identity + " to not have been called.", + "Expected spy " + this.actual.identity + " to have been called." + ]; + }; + + return !this.actual.wasCalled; +}; + +/** + * Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters. + * + * @example + * + */ +jasmine.Matchers.prototype.toHaveBeenCalledWith = function() { + var expectedArgs = jasmine.util.argsToArray(arguments); + if (!jasmine.isSpy(this.actual)) { + throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); + } + this.message = function() { + if (this.actual.callCount === 0) { + // todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw] + return [ + "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.", + "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was." + ]; + } else { + return [ + "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall), + "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall) + ]; + } + }; + + return this.env.contains_(this.actual.argsForCall, expectedArgs); +}; + +/** @deprecated Use expect(xxx).toHaveBeenCalledWith() instead */ +jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.prototype.toHaveBeenCalledWith; + +/** @deprecated Use expect(xxx).not.toHaveBeenCalledWith() instead */ +jasmine.Matchers.prototype.wasNotCalledWith = function() { + var expectedArgs = jasmine.util.argsToArray(arguments); + if (!jasmine.isSpy(this.actual)) { + throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); + } + + this.message = function() { + return [ + "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was", + "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was" + ]; + }; + + return !this.env.contains_(this.actual.argsForCall, expectedArgs); +}; + +/** + * Matcher that checks that the expected item is an element in the actual Array. + * + * @param {Object} expected + */ +jasmine.Matchers.prototype.toContain = function(expected) { + return this.env.contains_(this.actual, expected); +}; + +/** + * Matcher that checks that the expected item is NOT an element in the actual Array. + * + * @param {Object} expected + * @deprecated as of 1.0. Use not.toNotContain() instead. + */ +jasmine.Matchers.prototype.toNotContain = function(expected) { + return !this.env.contains_(this.actual, expected); +}; + +jasmine.Matchers.prototype.toBeLessThan = function(expected) { + return this.actual < expected; +}; + +jasmine.Matchers.prototype.toBeGreaterThan = function(expected) { + return this.actual > expected; +}; + +/** + * Matcher that checks that the expected item is equal to the actual item + * up to a given level of decimal precision (default 2). + * + * @param {Number} expected + * @param {Number} precision + */ +jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) { + if (!(precision === 0)) { + precision = precision || 2; + } + var multiplier = Math.pow(10, precision); + var actual = Math.round(this.actual * multiplier); + expected = Math.round(expected * multiplier); + return expected == actual; +}; + +/** + * Matcher that checks that the expected exception was thrown by the actual. + * + * @param {String} expected + */ +jasmine.Matchers.prototype.toThrow = function(expected) { + var result = false; + var exception; + if (typeof this.actual != 'function') { + throw new Error('Actual is not a function'); + } + try { + this.actual(); + } catch (e) { + exception = e; + } + if (exception) { + result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected)); + } + + var not = this.isNot ? "not " : ""; + + this.message = function() { + if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) { + return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' '); + } else { + return "Expected function to throw an exception."; + } + }; + + return result; +}; + +jasmine.Matchers.Any = function(expectedClass) { + this.expectedClass = expectedClass; +}; + +jasmine.Matchers.Any.prototype.matches = function(other) { + if (this.expectedClass == String) { + return typeof other == 'string' || other instanceof String; + } + + if (this.expectedClass == Number) { + return typeof other == 'number' || other instanceof Number; + } + + if (this.expectedClass == Function) { + return typeof other == 'function' || other instanceof Function; + } + + if (this.expectedClass == Object) { + return typeof other == 'object'; + } + + return other instanceof this.expectedClass; +}; + +jasmine.Matchers.Any.prototype.toString = function() { + return '<jasmine.any(' + this.expectedClass + ')>'; +}; + +/** + * @constructor + */ +jasmine.MultiReporter = function() { + this.subReporters_ = []; +}; +jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter); + +jasmine.MultiReporter.prototype.addReporter = function(reporter) { + this.subReporters_.push(reporter); +}; + +(function() { + var functionNames = [ + "reportRunnerStarting", + "reportRunnerResults", + "reportSuiteResults", + "reportSpecStarting", + "reportSpecResults", + "log" + ]; + for (var i = 0; i < functionNames.length; i++) { + var functionName = functionNames[i]; + jasmine.MultiReporter.prototype[functionName] = (function(functionName) { + return function() { + for (var j = 0; j < this.subReporters_.length; j++) { + var subReporter = this.subReporters_[j]; + if (subReporter[functionName]) { + subReporter[functionName].apply(subReporter, arguments); + } + } + }; + })(functionName); + } +})(); +/** + * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults + * + * @constructor + */ +jasmine.NestedResults = function() { + /** + * The total count of results + */ + this.totalCount = 0; + /** + * Number of passed results + */ + this.passedCount = 0; + /** + * Number of failed results + */ + this.failedCount = 0; + /** + * Was this suite/spec skipped? + */ + this.skipped = false; + /** + * @ignore + */ + this.items_ = []; +}; + +/** + * Roll up the result counts. + * + * @param result + */ +jasmine.NestedResults.prototype.rollupCounts = function(result) { + this.totalCount += result.totalCount; + this.passedCount += result.passedCount; + this.failedCount += result.failedCount; +}; + +/** + * Adds a log message. + * @param values Array of message parts which will be concatenated later. + */ +jasmine.NestedResults.prototype.log = function(values) { + this.items_.push(new jasmine.MessageResult(values)); +}; + +/** + * Getter for the results: message & results. + */ +jasmine.NestedResults.prototype.getItems = function() { + return this.items_; +}; + +/** + * Adds a result, tracking counts (total, passed, & failed) + * @param {jasmine.ExpectationResult|jasmine.NestedResults} result + */ +jasmine.NestedResults.prototype.addResult = function(result) { + if (result.type != 'log') { + if (result.items_) { + this.rollupCounts(result); + } else { + this.totalCount++; + if (result.passed()) { + this.passedCount++; + } else { + this.failedCount++; + } + } + } + this.items_.push(result); +}; + +/** + * @returns {Boolean} True if <b>everything</b> below passed + */ +jasmine.NestedResults.prototype.passed = function() { + return this.passedCount === this.totalCount; +}; +/** + * Base class for pretty printing for expectation results. + */ +jasmine.PrettyPrinter = function() { + this.ppNestLevel_ = 0; +}; + +/** + * Formats a value in a nice, human-readable string. + * + * @param value + */ +jasmine.PrettyPrinter.prototype.format = function(value) { + if (this.ppNestLevel_ > 40) { + throw new Error('jasmine.PrettyPrinter: format() nested too deeply!'); + } + + this.ppNestLevel_++; + try { + if (value === jasmine.undefined) { + this.emitScalar('undefined'); + } else if (value === null) { + this.emitScalar('null'); + } else if (value === jasmine.getGlobal()) { + this.emitScalar('<global>'); + } else if (value instanceof jasmine.Matchers.Any) { + this.emitScalar(value.toString()); + } else if (typeof value === 'string') { + this.emitString(value); + } else if (jasmine.isSpy(value)) { + this.emitScalar("spy on " + value.identity); + } else if (value instanceof RegExp) { + this.emitScalar(value.toString()); + } else if (typeof value === 'function') { + this.emitScalar('Function'); + } else if (typeof value.nodeType === 'number') { + this.emitScalar('HTMLNode'); + } else if (value instanceof Date) { + this.emitScalar('Date(' + value + ')'); + } else if (value.__Jasmine_been_here_before__) { + this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>'); + } else if (jasmine.isArray_(value) || typeof value == 'object') { + value.__Jasmine_been_here_before__ = true; + if (jasmine.isArray_(value)) { + this.emitArray(value); + } else { + this.emitObject(value); + } + delete value.__Jasmine_been_here_before__; + } else { + this.emitScalar(value.toString()); + } + } finally { + this.ppNestLevel_--; + } +}; + +jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) { + for (var property in obj) { + if (property == '__Jasmine_been_here_before__') continue; + fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined && + obj.__lookupGetter__(property) !== null) : false); + } +}; + +jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_; +jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_; +jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_; +jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_; + +jasmine.StringPrettyPrinter = function() { + jasmine.PrettyPrinter.call(this); + + this.string = ''; +}; +jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter); + +jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) { + this.append(value); +}; + +jasmine.StringPrettyPrinter.prototype.emitString = function(value) { + this.append("'" + value + "'"); +}; + +jasmine.StringPrettyPrinter.prototype.emitArray = function(array) { + this.append('[ '); + for (var i = 0; i < array.length; i++) { + if (i > 0) { + this.append(', '); + } + this.format(array[i]); + } + this.append(' ]'); +}; + +jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) { + var self = this; + this.append('{ '); + var first = true; + + this.iterateObject(obj, function(property, isGetter) { + if (first) { + first = false; + } else { + self.append(', '); + } + + self.append(property); + self.append(' : '); + if (isGetter) { + self.append('<getter>'); + } else { + self.format(obj[property]); + } + }); + + this.append(' }'); +}; + +jasmine.StringPrettyPrinter.prototype.append = function(value) { + this.string += value; +}; +jasmine.Queue = function(env) { + this.env = env; + this.blocks = []; + this.running = false; + this.index = 0; + this.offset = 0; + this.abort = false; +}; + +jasmine.Queue.prototype.addBefore = function(block) { + this.blocks.unshift(block); +}; + +jasmine.Queue.prototype.add = function(block) { + this.blocks.push(block); +}; + +jasmine.Queue.prototype.insertNext = function(block) { + this.blocks.splice((this.index + this.offset + 1), 0, block); + this.offset++; +}; + +jasmine.Queue.prototype.start = function(onComplete) { + this.running = true; + this.onComplete = onComplete; + this.next_(); +}; + +jasmine.Queue.prototype.isRunning = function() { + return this.running; +}; + +jasmine.Queue.LOOP_DONT_RECURSE = true; + +jasmine.Queue.prototype.next_ = function() { + var self = this; + var goAgain = true; + + while (goAgain) { + goAgain = false; + + if (self.index < self.blocks.length && !this.abort) { + var calledSynchronously = true; + var completedSynchronously = false; + + var onComplete = function () { + if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) { + completedSynchronously = true; + return; + } + + if (self.blocks[self.index].abort) { + self.abort = true; + } + + self.offset = 0; + self.index++; + + var now = new Date().getTime(); + if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) { + self.env.lastUpdate = now; + self.env.setTimeout(function() { + self.next_(); + }, 0); + } else { + if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) { + goAgain = true; + } else { + self.next_(); + } + } + }; + self.blocks[self.index].execute(onComplete); + + calledSynchronously = false; + if (completedSynchronously) { + onComplete(); + } + + } else { + self.running = false; + if (self.onComplete) { + self.onComplete(); + } + } + } +}; + +jasmine.Queue.prototype.results = function() { + var results = new jasmine.NestedResults(); + for (var i = 0; i < this.blocks.length; i++) { + if (this.blocks[i].results) { + results.addResult(this.blocks[i].results()); + } + } + return results; +}; + + +/** + * Runner + * + * @constructor + * @param {jasmine.Env} env + */ +jasmine.Runner = function(env) { + var self = this; + self.env = env; + self.queue = new jasmine.Queue(env); + self.before_ = []; + self.after_ = []; + self.suites_ = []; +}; + +jasmine.Runner.prototype.execute = function() { + var self = this; + if (self.env.reporter.reportRunnerStarting) { + self.env.reporter.reportRunnerStarting(this); + } + self.queue.start(function () { + self.finishCallback(); + }); +}; + +jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) { + beforeEachFunction.typeName = 'beforeEach'; + this.before_.splice(0,0,beforeEachFunction); +}; + +jasmine.Runner.prototype.afterEach = function(afterEachFunction) { + afterEachFunction.typeName = 'afterEach'; + this.after_.splice(0,0,afterEachFunction); +}; + + +jasmine.Runner.prototype.finishCallback = function() { + this.env.reporter.reportRunnerResults(this); +}; + +jasmine.Runner.prototype.addSuite = function(suite) { + this.suites_.push(suite); +}; + +jasmine.Runner.prototype.add = function(block) { + if (block instanceof jasmine.Suite) { + this.addSuite(block); + } + this.queue.add(block); +}; + +jasmine.Runner.prototype.specs = function () { + var suites = this.suites(); + var specs = []; + for (var i = 0; i < suites.length; i++) { + specs = specs.concat(suites[i].specs()); + } + return specs; +}; + +jasmine.Runner.prototype.suites = function() { + return this.suites_; +}; + +jasmine.Runner.prototype.topLevelSuites = function() { + var topLevelSuites = []; + for (var i = 0; i < this.suites_.length; i++) { + if (!this.suites_[i].parentSuite) { + topLevelSuites.push(this.suites_[i]); + } + } + return topLevelSuites; +}; + +jasmine.Runner.prototype.results = function() { + return this.queue.results(); +}; +/** + * Internal representation of a Jasmine specification, or test. + * + * @constructor + * @param {jasmine.Env} env + * @param {jasmine.Suite} suite + * @param {String} description + */ +jasmine.Spec = function(env, suite, description) { + if (!env) { + throw new Error('jasmine.Env() required'); + } + if (!suite) { + throw new Error('jasmine.Suite() required'); + } + var spec = this; + spec.id = env.nextSpecId ? env.nextSpecId() : null; + spec.env = env; + spec.suite = suite; + spec.description = description; + spec.queue = new jasmine.Queue(env); + + spec.afterCallbacks = []; + spec.spies_ = []; + + spec.results_ = new jasmine.NestedResults(); + spec.results_.description = description; + spec.matchersClass = null; +}; + +jasmine.Spec.prototype.getFullName = function() { + return this.suite.getFullName() + ' ' + this.description + '.'; +}; + + +jasmine.Spec.prototype.results = function() { + return this.results_; +}; + +/** + * All parameters are pretty-printed and concatenated together, then written to the spec's output. + * + * Be careful not to leave calls to <code>jasmine.log</code> in production code. + */ +jasmine.Spec.prototype.log = function() { + return this.results_.log(arguments); +}; + +jasmine.Spec.prototype.runs = function (func) { + var block = new jasmine.Block(this.env, func, this); + this.addToQueue(block); + return this; +}; + +jasmine.Spec.prototype.addToQueue = function (block) { + if (this.queue.isRunning()) { + this.queue.insertNext(block); + } else { + this.queue.add(block); + } +}; + +/** + * @param {jasmine.ExpectationResult} result + */ +jasmine.Spec.prototype.addMatcherResult = function(result) { + this.results_.addResult(result); +}; + +jasmine.Spec.prototype.expect = function(actual) { + var positive = new (this.getMatchersClass_())(this.env, actual, this); + positive.not = new (this.getMatchersClass_())(this.env, actual, this, true); + return positive; +}; + +/** + * Waits a fixed time period before moving to the next block. + * + * @deprecated Use waitsFor() instead + * @param {Number} timeout milliseconds to wait + */ +jasmine.Spec.prototype.waits = function(timeout) { + var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this); + this.addToQueue(waitsFunc); + return this; +}; + +/** + * Waits for the latchFunction to return true before proceeding to the next block. + * + * @param {Function} latchFunction + * @param {String} optional_timeoutMessage + * @param {Number} optional_timeout + */ +jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) { + var latchFunction_ = null; + var optional_timeoutMessage_ = null; + var optional_timeout_ = null; + + for (var i = 0; i < arguments.length; i++) { + var arg = arguments[i]; + switch (typeof arg) { + case 'function': + latchFunction_ = arg; + break; + case 'string': + optional_timeoutMessage_ = arg; + break; + case 'number': + optional_timeout_ = arg; + break; + } + } + + var waitsForFunc = new jasmine.WaitsForBlock(this.env, optional_timeout_, latchFunction_, optional_timeoutMessage_, this); + this.addToQueue(waitsForFunc); + return this; +}; + +jasmine.Spec.prototype.fail = function (e) { + var expectationResult = new jasmine.ExpectationResult({ + passed: false, + message: e ? jasmine.util.formatException(e) : 'Exception', + trace: { stack: e.stack } + }); + this.results_.addResult(expectationResult); +}; + +jasmine.Spec.prototype.getMatchersClass_ = function() { + return this.matchersClass || this.env.matchersClass; +}; + +jasmine.Spec.prototype.addMatchers = function(matchersPrototype) { + var parent = this.getMatchersClass_(); + var newMatchersClass = function() { + parent.apply(this, arguments); + }; + jasmine.util.inherit(newMatchersClass, parent); + jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass); + this.matchersClass = newMatchersClass; +}; + +jasmine.Spec.prototype.finishCallback = function() { + this.env.reporter.reportSpecResults(this); +}; + +jasmine.Spec.prototype.finish = function(onComplete) { + this.removeAllSpies(); + this.finishCallback(); + if (onComplete) { + onComplete(); + } +}; + +jasmine.Spec.prototype.after = function(doAfter) { + if (this.queue.isRunning()) { + this.queue.add(new jasmine.Block(this.env, doAfter, this)); + } else { + this.afterCallbacks.unshift(doAfter); + } +}; + +jasmine.Spec.prototype.execute = function(onComplete) { + var spec = this; + if (!spec.env.specFilter(spec)) { + spec.results_.skipped = true; + spec.finish(onComplete); + return; + } + + this.env.reporter.reportSpecStarting(this); + + spec.env.currentSpec = spec; + + spec.addBeforesAndAftersToQueue(); + + spec.queue.start(function () { + spec.finish(onComplete); + }); +}; + +jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() { + var runner = this.env.currentRunner(); + var i; + + for (var suite = this.suite; suite; suite = suite.parentSuite) { + for (i = 0; i < suite.before_.length; i++) { + this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this)); + } + } + for (i = 0; i < runner.before_.length; i++) { + this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this)); + } + for (i = 0; i < this.afterCallbacks.length; i++) { + this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this)); + } + for (suite = this.suite; suite; suite = suite.parentSuite) { + for (i = 0; i < suite.after_.length; i++) { + this.queue.add(new jasmine.Block(this.env, suite.after_[i], this)); + } + } + for (i = 0; i < runner.after_.length; i++) { + this.queue.add(new jasmine.Block(this.env, runner.after_[i], this)); + } +}; + +jasmine.Spec.prototype.explodes = function() { + throw 'explodes function should not have been called'; +}; + +jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) { + if (obj == jasmine.undefined) { + throw "spyOn could not find an object to spy upon for " + methodName + "()"; + } + + if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) { + throw methodName + '() method does not exist'; + } + + if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) { + throw new Error(methodName + ' has already been spied upon'); + } + + var spyObj = jasmine.createSpy(methodName); + + this.spies_.push(spyObj); + spyObj.baseObj = obj; + spyObj.methodName = methodName; + spyObj.originalValue = obj[methodName]; + + obj[methodName] = spyObj; + + return spyObj; +}; + +jasmine.Spec.prototype.removeAllSpies = function() { + for (var i = 0; i < this.spies_.length; i++) { + var spy = this.spies_[i]; + spy.baseObj[spy.methodName] = spy.originalValue; + } + this.spies_ = []; +}; + +/** + * Internal representation of a Jasmine suite. + * + * @constructor + * @param {jasmine.Env} env + * @param {String} description + * @param {Function} specDefinitions + * @param {jasmine.Suite} parentSuite + */ +jasmine.Suite = function(env, description, specDefinitions, parentSuite) { + var self = this; + self.id = env.nextSuiteId ? env.nextSuiteId() : null; + self.description = description; + self.queue = new jasmine.Queue(env); + self.parentSuite = parentSuite; + self.env = env; + self.before_ = []; + self.after_ = []; + self.children_ = []; + self.suites_ = []; + self.specs_ = []; +}; + +jasmine.Suite.prototype.getFullName = function() { + var fullName = this.description; + for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { + fullName = parentSuite.description + ' ' + fullName; + } + return fullName; +}; + +jasmine.Suite.prototype.finish = function(onComplete) { + this.env.reporter.reportSuiteResults(this); + this.finished = true; + if (typeof(onComplete) == 'function') { + onComplete(); + } +}; + +jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) { + beforeEachFunction.typeName = 'beforeEach'; + this.before_.unshift(beforeEachFunction); +}; + +jasmine.Suite.prototype.afterEach = function(afterEachFunction) { + afterEachFunction.typeName = 'afterEach'; + this.after_.unshift(afterEachFunction); +}; + +jasmine.Suite.prototype.results = function() { + return this.queue.results(); +}; + +jasmine.Suite.prototype.add = function(suiteOrSpec) { + this.children_.push(suiteOrSpec); + if (suiteOrSpec instanceof jasmine.Suite) { + this.suites_.push(suiteOrSpec); + this.env.currentRunner().addSuite(suiteOrSpec); + } else { + this.specs_.push(suiteOrSpec); + } + this.queue.add(suiteOrSpec); +}; + +jasmine.Suite.prototype.specs = function() { + return this.specs_; +}; + +jasmine.Suite.prototype.suites = function() { + return this.suites_; +}; + +jasmine.Suite.prototype.children = function() { + return this.children_; +}; + +jasmine.Suite.prototype.execute = function(onComplete) { + var self = this; + this.queue.start(function () { + self.finish(onComplete); + }); +}; +jasmine.WaitsBlock = function(env, timeout, spec) { + this.timeout = timeout; + jasmine.Block.call(this, env, null, spec); +}; + +jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block); + +jasmine.WaitsBlock.prototype.execute = function (onComplete) { + if (jasmine.VERBOSE) { + this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...'); + } + this.env.setTimeout(function () { + onComplete(); + }, this.timeout); +}; +/** + * A block which waits for some condition to become true, with timeout. + * + * @constructor + * @extends jasmine.Block + * @param {jasmine.Env} env The Jasmine environment. + * @param {Number} timeout The maximum time in milliseconds to wait for the condition to become true. + * @param {Function} latchFunction A function which returns true when the desired condition has been met. + * @param {String} message The message to display if the desired condition hasn't been met within the given time period. + * @param {jasmine.Spec} spec The Jasmine spec. + */ +jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) { + this.timeout = timeout || env.defaultTimeoutInterval; + this.latchFunction = latchFunction; + this.message = message; + this.totalTimeSpentWaitingForLatch = 0; + jasmine.Block.call(this, env, null, spec); +}; +jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block); + +jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10; + +jasmine.WaitsForBlock.prototype.execute = function(onComplete) { + if (jasmine.VERBOSE) { + this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen')); + } + var latchFunctionResult; + try { + latchFunctionResult = this.latchFunction.apply(this.spec); + } catch (e) { + this.spec.fail(e); + onComplete(); + return; + } + + if (latchFunctionResult) { + onComplete(); + } else if (this.totalTimeSpentWaitingForLatch >= this.timeout) { + var message = 'timed out after ' + this.timeout + ' msec waiting for ' + (this.message || 'something to happen'); + this.spec.fail({ + name: 'timeout', + message: message + }); + + this.abort = true; + onComplete(); + } else { + this.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT; + var self = this; + this.env.setTimeout(function() { + self.execute(onComplete); + }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT); + } +}; +// Mock setTimeout, clearTimeout +// Contributed by Pivotal Computer Systems, www.pivotalsf.com + +jasmine.FakeTimer = function() { + this.reset(); + + var self = this; + self.setTimeout = function(funcToCall, millis) { + self.timeoutsMade++; + self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false); + return self.timeoutsMade; + }; + + self.setInterval = function(funcToCall, millis) { + self.timeoutsMade++; + self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true); + return self.timeoutsMade; + }; + + self.clearTimeout = function(timeoutKey) { + self.scheduledFunctions[timeoutKey] = jasmine.undefined; + }; + + self.clearInterval = function(timeoutKey) { + self.scheduledFunctions[timeoutKey] = jasmine.undefined; + }; + +}; + +jasmine.FakeTimer.prototype.reset = function() { + this.timeoutsMade = 0; + this.scheduledFunctions = {}; + this.nowMillis = 0; +}; + +jasmine.FakeTimer.prototype.tick = function(millis) { + var oldMillis = this.nowMillis; + var newMillis = oldMillis + millis; + this.runFunctionsWithinRange(oldMillis, newMillis); + this.nowMillis = newMillis; +}; + +jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) { + var scheduledFunc; + var funcsToRun = []; + for (var timeoutKey in this.scheduledFunctions) { + scheduledFunc = this.scheduledFunctions[timeoutKey]; + if (scheduledFunc != jasmine.undefined && + scheduledFunc.runAtMillis >= oldMillis && + scheduledFunc.runAtMillis <= nowMillis) { + funcsToRun.push(scheduledFunc); + this.scheduledFunctions[timeoutKey] = jasmine.undefined; + } + } + + if (funcsToRun.length > 0) { + funcsToRun.sort(function(a, b) { + return a.runAtMillis - b.runAtMillis; + }); + for (var i = 0; i < funcsToRun.length; ++i) { + try { + var funcToRun = funcsToRun[i]; + this.nowMillis = funcToRun.runAtMillis; + funcToRun.funcToCall(); + if (funcToRun.recurring) { + this.scheduleFunction(funcToRun.timeoutKey, + funcToRun.funcToCall, + funcToRun.millis, + true); + } + } catch(e) { + } + } + this.runFunctionsWithinRange(oldMillis, nowMillis); + } +}; + +jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) { + this.scheduledFunctions[timeoutKey] = { + runAtMillis: this.nowMillis + millis, + funcToCall: funcToCall, + recurring: recurring, + timeoutKey: timeoutKey, + millis: millis + }; +}; + +/** + * @namespace + */ +jasmine.Clock = { + defaultFakeTimer: new jasmine.FakeTimer(), + + reset: function() { + jasmine.Clock.assertInstalled(); + jasmine.Clock.defaultFakeTimer.reset(); + }, + + tick: function(millis) { + jasmine.Clock.assertInstalled(); + jasmine.Clock.defaultFakeTimer.tick(millis); + }, + + runFunctionsWithinRange: function(oldMillis, nowMillis) { + jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis); + }, + + scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) { + jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring); + }, + + useMock: function() { + if (!jasmine.Clock.isInstalled()) { + var spec = jasmine.getEnv().currentSpec; + spec.after(jasmine.Clock.uninstallMock); + + jasmine.Clock.installMock(); + } + }, + + installMock: function() { + jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer; + }, + + uninstallMock: function() { + jasmine.Clock.assertInstalled(); + jasmine.Clock.installed = jasmine.Clock.real; + }, + + real: { + setTimeout: jasmine.getGlobal().setTimeout, + clearTimeout: jasmine.getGlobal().clearTimeout, + setInterval: jasmine.getGlobal().setInterval, + clearInterval: jasmine.getGlobal().clearInterval + }, + + assertInstalled: function() { + if (!jasmine.Clock.isInstalled()) { + throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()"); + } + }, + + isInstalled: function() { + return jasmine.Clock.installed == jasmine.Clock.defaultFakeTimer; + }, + + installed: null +}; +jasmine.Clock.installed = jasmine.Clock.real; + +//else for IE support +jasmine.getGlobal().setTimeout = function(funcToCall, millis) { + if (jasmine.Clock.installed.setTimeout.apply) { + return jasmine.Clock.installed.setTimeout.apply(this, arguments); + } else { + return jasmine.Clock.installed.setTimeout(funcToCall, millis); + } +}; + +jasmine.getGlobal().setInterval = function(funcToCall, millis) { + if (jasmine.Clock.installed.setInterval.apply) { + return jasmine.Clock.installed.setInterval.apply(this, arguments); + } else { + return jasmine.Clock.installed.setInterval(funcToCall, millis); + } +}; + +jasmine.getGlobal().clearTimeout = function(timeoutKey) { + if (jasmine.Clock.installed.clearTimeout.apply) { + return jasmine.Clock.installed.clearTimeout.apply(this, arguments); + } else { + return jasmine.Clock.installed.clearTimeout(timeoutKey); + } +}; + +jasmine.getGlobal().clearInterval = function(timeoutKey) { + if (jasmine.Clock.installed.clearTimeout.apply) { + return jasmine.Clock.installed.clearInterval.apply(this, arguments); + } else { + return jasmine.Clock.installed.clearInterval(timeoutKey); + } +}; + +jasmine.version_= { + "major": 1, + "minor": 1, + "build": 0, + "revision": 1320442951 +}; diff --git a/addons/web/static/lib/pdfjs/external/jasmine/jasmine_favicon.png b/addons/web/static/lib/pdfjs/external/jasmine/jasmine_favicon.png Binary files differnew file mode 100644 index 00000000000..81ad355d8f7 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/jasmine/jasmine_favicon.png diff --git a/addons/web/static/lib/pdfjs/external/webL10n/README.md b/addons/web/static/lib/pdfjs/external/webL10n/README.md new file mode 100644 index 00000000000..52995522cb2 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/webL10n/README.md @@ -0,0 +1,3 @@ +The source code for the library can be found at + + https://github.com/fabi1cazenave/webL10n diff --git a/addons/web/static/lib/pdfjs/external/webL10n/l10n.js b/addons/web/static/lib/pdfjs/external/webL10n/l10n.js new file mode 100644 index 00000000000..3d5ecffaf54 --- /dev/null +++ b/addons/web/static/lib/pdfjs/external/webL10n/l10n.js @@ -0,0 +1,1033 @@ +/** + * Copyright (c) 2011-2013 Fabien Cazenave, Mozilla. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ +/* + Additional modifications for PDF.js project: + - Disables language initialization on page loading; + - Removes consoleWarn and consoleLog and use console.log/warn directly. + - Removes window._ assignment. + - Remove compatibility code for OldIE. +*/ + +/*jshint browser: true, devel: true, es5: true, globalstrict: true */ +'use strict'; + +document.webL10n = (function(window, document, undefined) { + var gL10nData = {}; + var gTextData = ''; + var gTextProp = 'textContent'; + var gLanguage = ''; + var gMacros = {}; + var gReadyState = 'loading'; + + + /** + * Synchronously loading l10n resources significantly minimizes flickering + * from displaying the app with non-localized strings and then updating the + * strings. Although this will block all script execution on this page, we + * expect that the l10n resources are available locally on flash-storage. + * + * As synchronous XHR is generally considered as a bad idea, we're still + * loading l10n resources asynchronously -- but we keep this in a setting, + * just in case... and applications using this library should hide their + * content until the `localized' event happens. + */ + + var gAsyncResourceLoading = true; // read-only + + + /** + * DOM helpers for the so-called "HTML API". + * + * These functions are written for modern browsers. For old versions of IE, + * they're overridden in the 'startup' section at the end of this file. + */ + + function getL10nResourceLinks() { + return document.querySelectorAll('link[type="application/l10n"]'); + } + + function getL10nDictionary() { + var script = document.querySelector('script[type="application/l10n"]'); + // TODO: support multiple and external JSON dictionaries + return script ? JSON.parse(script.innerHTML) : null; + } + + function getTranslatableChildren(element) { + return element ? element.querySelectorAll('*[data-l10n-id]') : []; + } + + function getL10nAttributes(element) { + if (!element) + return {}; + + var l10nId = element.getAttribute('data-l10n-id'); + var l10nArgs = element.getAttribute('data-l10n-args'); + var args = {}; + if (l10nArgs) { + try { + args = JSON.parse(l10nArgs); + } catch (e) { + console.warn('could not parse arguments for #' + l10nId); + } + } + return { id: l10nId, args: args }; + } + + function fireL10nReadyEvent(lang) { + var evtObject = document.createEvent('Event'); + evtObject.initEvent('localized', true, false); + evtObject.language = lang; + document.dispatchEvent(evtObject); + } + + function xhrLoadText(url, onSuccess, onFailure) { + onSuccess = onSuccess || function _onSuccess(data) {}; + onFailure = onFailure || function _onFailure() { + console.warn(url + ' not found.'); + }; + + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, gAsyncResourceLoading); + if (xhr.overrideMimeType) { + xhr.overrideMimeType('text/plain; charset=utf-8'); + } + xhr.onreadystatechange = function() { + if (xhr.readyState == 4) { + if (xhr.status == 200 || xhr.status === 0) { + onSuccess(xhr.responseText); + } else { + onFailure(); + } + } + }; + xhr.onerror = onFailure; + xhr.ontimeout = onFailure; + + // in Firefox OS with the app:// protocol, trying to XHR a non-existing + // URL will raise an exception here -- hence this ugly try...catch. + try { + xhr.send(null); + } catch (e) { + onFailure(); + } + } + + + /** + * l10n resource parser: + * - reads (async XHR) the l10n resource matching `lang'; + * - imports linked resources (synchronously) when specified; + * - parses the text data (fills `gL10nData' and `gTextData'); + * - triggers success/failure callbacks when done. + * + * @param {string} href + * URL of the l10n resource to parse. + * + * @param {string} lang + * locale (language) to parse. Must be a lowercase string. + * + * @param {Function} successCallback + * triggered when the l10n resource has been successully parsed. + * + * @param {Function} failureCallback + * triggered when the an error has occured. + * + * @return {void} + * uses the following global variables: gL10nData, gTextData, gTextProp. + */ + + function parseResource(href, lang, successCallback, failureCallback) { + var baseURL = href.replace(/[^\/]*$/, '') || './'; + + // handle escaped characters (backslashes) in a string + function evalString(text) { + if (text.lastIndexOf('\\') < 0) + return text; + return text.replace(/\\\\/g, '\\') + .replace(/\\n/g, '\n') + .replace(/\\r/g, '\r') + .replace(/\\t/g, '\t') + .replace(/\\b/g, '\b') + .replace(/\\f/g, '\f') + .replace(/\\{/g, '{') + .replace(/\\}/g, '}') + .replace(/\\"/g, '"') + .replace(/\\'/g, "'"); + } + + // parse *.properties text data into an l10n dictionary + // If gAsyncResourceLoading is false, then the callback will be called + // synchronously. Otherwise it is called asynchronously. + function parseProperties(text, parsedPropertiesCallback) { + var dictionary = {}; + + // token expressions + var reBlank = /^\s*|\s*$/; + var reComment = /^\s*#|^\s*$/; + var reSection = /^\s*\[(.*)\]\s*$/; + var reImport = /^\s*@import\s+url\((.*)\)\s*$/i; + var reSplit = /^([^=\s]*)\s*=\s*(.+)$/; // TODO: escape EOLs with '\' + + // parse the *.properties file into an associative array + function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) { + var entries = rawText.replace(reBlank, '').split(/[\r\n]+/); + var currentLang = '*'; + var genericLang = lang.split('-', 1)[0]; + var skipLang = false; + var match = ''; + + function nextEntry() { + // Use infinite loop instead of recursion to avoid reaching the + // maximum recursion limit for content with many lines. + while (true) { + if (!entries.length) { + parsedRawLinesCallback(); + return; + } + var line = entries.shift(); + + // comment or blank line? + if (reComment.test(line)) + continue; + + // the extended syntax supports [lang] sections and @import rules + if (extendedSyntax) { + match = reSection.exec(line); + if (match) { // section start? + // RFC 4646, section 4.4, "All comparisons MUST be performed + // in a case-insensitive manner." + + currentLang = match[1].toLowerCase(); + skipLang = (currentLang !== '*') && + (currentLang !== lang) && (currentLang !== genericLang); + continue; + } else if (skipLang) { + continue; + } + match = reImport.exec(line); + if (match) { // @import rule? + loadImport(baseURL + match[1], nextEntry); + return; + } + } + + // key-value pair + var tmp = line.match(reSplit); + if (tmp && tmp.length == 3) { + dictionary[tmp[1]] = evalString(tmp[2]); + } + } + } + nextEntry(); + } + + // import another *.properties file + function loadImport(url, callback) { + xhrLoadText(url, function(content) { + parseRawLines(content, false, callback); // don't allow recursive imports + }, null); + } + + // fill the dictionary + parseRawLines(text, true, function() { + parsedPropertiesCallback(dictionary); + }); + } + + // load and parse l10n data (warning: global variables are used here) + xhrLoadText(href, function(response) { + gTextData += response; // mostly for debug + + // parse *.properties text data into an l10n dictionary + parseProperties(response, function(data) { + + // find attribute descriptions, if any + for (var key in data) { + var id, prop, index = key.lastIndexOf('.'); + if (index > 0) { // an attribute has been specified + id = key.substring(0, index); + prop = key.substr(index + 1); + } else { // no attribute: assuming text content by default + id = key; + prop = gTextProp; + } + if (!gL10nData[id]) { + gL10nData[id] = {}; + } + gL10nData[id][prop] = data[key]; + } + + // trigger callback + if (successCallback) { + successCallback(); + } + }); + }, failureCallback); + } + + // load and parse all resources for the specified locale + function loadLocale(lang, callback) { + // RFC 4646, section 2.1 states that language tags have to be treated as + // case-insensitive. Convert to lowercase for case-insensitive comparisons. + if (lang) { + lang = lang.toLowerCase(); + } + + callback = callback || function _callback() {}; + + clear(); + gLanguage = lang; + + // check all <link type="application/l10n" href="..." /> nodes + // and load the resource files + var langLinks = getL10nResourceLinks(); + var langCount = langLinks.length; + if (langCount === 0) { + // we might have a pre-compiled dictionary instead + var dict = getL10nDictionary(); + if (dict && dict.locales && dict.default_locale) { + console.log('using the embedded JSON directory, early way out'); + gL10nData = dict.locales[lang]; + if (!gL10nData) { + var defaultLocale = dict.default_locale.toLowerCase(); + for (var anyCaseLang in dict.locales) { + anyCaseLang = anyCaseLang.toLowerCase(); + if (anyCaseLang === lang) { + gL10nData = dict.locales[lang]; + break; + } else if (anyCaseLang === defaultLocale) { + gL10nData = dict.locales[defaultLocale]; + } + } + } + callback(); + } else { + console.log('no resource to load, early way out'); + } + // early way out + fireL10nReadyEvent(lang); + gReadyState = 'complete'; + return; + } + + // start the callback when all resources are loaded + var onResourceLoaded = null; + var gResourceCount = 0; + onResourceLoaded = function() { + gResourceCount++; + if (gResourceCount >= langCount) { + callback(); + fireL10nReadyEvent(lang); + gReadyState = 'complete'; + } + }; + + // load all resource files + function L10nResourceLink(link) { + var href = link.href; + // Note: If |gAsyncResourceLoading| is false, then the following callbacks + // are synchronously called. + this.load = function(lang, callback) { + parseResource(href, lang, callback, function() { + console.warn(href + ' not found.'); + // lang not found, used default resource instead + console.warn('"' + lang + '" resource not found'); + gLanguage = ''; + // Resource not loaded, but we still need to call the callback. + callback(); + }); + }; + } + + for (var i = 0; i < langCount; i++) { + var resource = new L10nResourceLink(langLinks[i]); + resource.load(lang, onResourceLoaded); + } + } + + // clear all l10n data + function clear() { + gL10nData = {}; + gTextData = ''; + gLanguage = ''; + // TODO: clear all non predefined macros. + // There's no such macro /yet/ but we're planning to have some... + } + + + /** + * Get rules for plural forms (shared with JetPack), see: + * http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html + * https://github.com/mozilla/addon-sdk/blob/master/python-lib/plural-rules-generator.p + * + * @param {string} lang + * locale (language) used. + * + * @return {Function} + * returns a function that gives the plural form name for a given integer: + * var fun = getPluralRules('en'); + * fun(1) -> 'one' + * fun(0) -> 'other' + * fun(1000) -> 'other'. + */ + + function getPluralRules(lang) { + var locales2rules = { + 'af': 3, + 'ak': 4, + 'am': 4, + 'ar': 1, + 'asa': 3, + 'az': 0, + 'be': 11, + 'bem': 3, + 'bez': 3, + 'bg': 3, + 'bh': 4, + 'bm': 0, + 'bn': 3, + 'bo': 0, + 'br': 20, + 'brx': 3, + 'bs': 11, + 'ca': 3, + 'cgg': 3, + 'chr': 3, + 'cs': 12, + 'cy': 17, + 'da': 3, + 'de': 3, + 'dv': 3, + 'dz': 0, + 'ee': 3, + 'el': 3, + 'en': 3, + 'eo': 3, + 'es': 3, + 'et': 3, + 'eu': 3, + 'fa': 0, + 'ff': 5, + 'fi': 3, + 'fil': 4, + 'fo': 3, + 'fr': 5, + 'fur': 3, + 'fy': 3, + 'ga': 8, + 'gd': 24, + 'gl': 3, + 'gsw': 3, + 'gu': 3, + 'guw': 4, + 'gv': 23, + 'ha': 3, + 'haw': 3, + 'he': 2, + 'hi': 4, + 'hr': 11, + 'hu': 0, + 'id': 0, + 'ig': 0, + 'ii': 0, + 'is': 3, + 'it': 3, + 'iu': 7, + 'ja': 0, + 'jmc': 3, + 'jv': 0, + 'ka': 0, + 'kab': 5, + 'kaj': 3, + 'kcg': 3, + 'kde': 0, + 'kea': 0, + 'kk': 3, + 'kl': 3, + 'km': 0, + 'kn': 0, + 'ko': 0, + 'ksb': 3, + 'ksh': 21, + 'ku': 3, + 'kw': 7, + 'lag': 18, + 'lb': 3, + 'lg': 3, + 'ln': 4, + 'lo': 0, + 'lt': 10, + 'lv': 6, + 'mas': 3, + 'mg': 4, + 'mk': 16, + 'ml': 3, + 'mn': 3, + 'mo': 9, + 'mr': 3, + 'ms': 0, + 'mt': 15, + 'my': 0, + 'nah': 3, + 'naq': 7, + 'nb': 3, + 'nd': 3, + 'ne': 3, + 'nl': 3, + 'nn': 3, + 'no': 3, + 'nr': 3, + 'nso': 4, + 'ny': 3, + 'nyn': 3, + 'om': 3, + 'or': 3, + 'pa': 3, + 'pap': 3, + 'pl': 13, + 'ps': 3, + 'pt': 3, + 'rm': 3, + 'ro': 9, + 'rof': 3, + 'ru': 11, + 'rwk': 3, + 'sah': 0, + 'saq': 3, + 'se': 7, + 'seh': 3, + 'ses': 0, + 'sg': 0, + 'sh': 11, + 'shi': 19, + 'sk': 12, + 'sl': 14, + 'sma': 7, + 'smi': 7, + 'smj': 7, + 'smn': 7, + 'sms': 7, + 'sn': 3, + 'so': 3, + 'sq': 3, + 'sr': 11, + 'ss': 3, + 'ssy': 3, + 'st': 3, + 'sv': 3, + 'sw': 3, + 'syr': 3, + 'ta': 3, + 'te': 3, + 'teo': 3, + 'th': 0, + 'ti': 4, + 'tig': 3, + 'tk': 3, + 'tl': 4, + 'tn': 3, + 'to': 0, + 'tr': 0, + 'ts': 3, + 'tzm': 22, + 'uk': 11, + 'ur': 3, + 've': 3, + 'vi': 0, + 'vun': 3, + 'wa': 4, + 'wae': 3, + 'wo': 0, + 'xh': 3, + 'xog': 3, + 'yo': 0, + 'zh': 0, + 'zu': 3 + }; + + // utility functions for plural rules methods + function isIn(n, list) { + return list.indexOf(n) !== -1; + } + function isBetween(n, start, end) { + return start <= n && n <= end; + } + + // list of all plural rules methods: + // map an integer to the plural form name to use + var pluralRules = { + '0': function(n) { + return 'other'; + }, + '1': function(n) { + if ((isBetween((n % 100), 3, 10))) + return 'few'; + if (n === 0) + return 'zero'; + if ((isBetween((n % 100), 11, 99))) + return 'many'; + if (n == 2) + return 'two'; + if (n == 1) + return 'one'; + return 'other'; + }, + '2': function(n) { + if (n !== 0 && (n % 10) === 0) + return 'many'; + if (n == 2) + return 'two'; + if (n == 1) + return 'one'; + return 'other'; + }, + '3': function(n) { + if (n == 1) + return 'one'; + return 'other'; + }, + '4': function(n) { + if ((isBetween(n, 0, 1))) + return 'one'; + return 'other'; + }, + '5': function(n) { + if ((isBetween(n, 0, 2)) && n != 2) + return 'one'; + return 'other'; + }, + '6': function(n) { + if (n === 0) + return 'zero'; + if ((n % 10) == 1 && (n % 100) != 11) + return 'one'; + return 'other'; + }, + '7': function(n) { + if (n == 2) + return 'two'; + if (n == 1) + return 'one'; + return 'other'; + }, + '8': function(n) { + if ((isBetween(n, 3, 6))) + return 'few'; + if ((isBetween(n, 7, 10))) + return 'many'; + if (n == 2) + return 'two'; + if (n == 1) + return 'one'; + return 'other'; + }, + '9': function(n) { + if (n === 0 || n != 1 && (isBetween((n % 100), 1, 19))) + return 'few'; + if (n == 1) + return 'one'; + return 'other'; + }, + '10': function(n) { + if ((isBetween((n % 10), 2, 9)) && !(isBetween((n % 100), 11, 19))) + return 'few'; + if ((n % 10) == 1 && !(isBetween((n % 100), 11, 19))) + return 'one'; + return 'other'; + }, + '11': function(n) { + if ((isBetween((n % 10), 2, 4)) && !(isBetween((n % 100), 12, 14))) + return 'few'; + if ((n % 10) === 0 || + (isBetween((n % 10), 5, 9)) || + (isBetween((n % 100), 11, 14))) + return 'many'; + if ((n % 10) == 1 && (n % 100) != 11) + return 'one'; + return 'other'; + }, + '12': function(n) { + if ((isBetween(n, 2, 4))) + return 'few'; + if (n == 1) + return 'one'; + return 'other'; + }, + '13': function(n) { + if ((isBetween((n % 10), 2, 4)) && !(isBetween((n % 100), 12, 14))) + return 'few'; + if (n != 1 && (isBetween((n % 10), 0, 1)) || + (isBetween((n % 10), 5, 9)) || + (isBetween((n % 100), 12, 14))) + return 'many'; + if (n == 1) + return 'one'; + return 'other'; + }, + '14': function(n) { + if ((isBetween((n % 100), 3, 4))) + return 'few'; + if ((n % 100) == 2) + return 'two'; + if ((n % 100) == 1) + return 'one'; + return 'other'; + }, + '15': function(n) { + if (n === 0 || (isBetween((n % 100), 2, 10))) + return 'few'; + if ((isBetween((n % 100), 11, 19))) + return 'many'; + if (n == 1) + return 'one'; + return 'other'; + }, + '16': function(n) { + if ((n % 10) == 1 && n != 11) + return 'one'; + return 'other'; + }, + '17': function(n) { + if (n == 3) + return 'few'; + if (n === 0) + return 'zero'; + if (n == 6) + return 'many'; + if (n == 2) + return 'two'; + if (n == 1) + return 'one'; + return 'other'; + }, + '18': function(n) { + if (n === 0) + return 'zero'; + if ((isBetween(n, 0, 2)) && n !== 0 && n != 2) + return 'one'; + return 'other'; + }, + '19': function(n) { + if ((isBetween(n, 2, 10))) + return 'few'; + if ((isBetween(n, 0, 1))) + return 'one'; + return 'other'; + }, + '20': function(n) { + if ((isBetween((n % 10), 3, 4) || ((n % 10) == 9)) && !( + isBetween((n % 100), 10, 19) || + isBetween((n % 100), 70, 79) || + isBetween((n % 100), 90, 99) + )) + return 'few'; + if ((n % 1000000) === 0 && n !== 0) + return 'many'; + if ((n % 10) == 2 && !isIn((n % 100), [12, 72, 92])) + return 'two'; + if ((n % 10) == 1 && !isIn((n % 100), [11, 71, 91])) + return 'one'; + return 'other'; + }, + '21': function(n) { + if (n === 0) + return 'zero'; + if (n == 1) + return 'one'; + return 'other'; + }, + '22': function(n) { + if ((isBetween(n, 0, 1)) || (isBetween(n, 11, 99))) + return 'one'; + return 'other'; + }, + '23': function(n) { + if ((isBetween((n % 10), 1, 2)) || (n % 20) === 0) + return 'one'; + return 'other'; + }, + '24': function(n) { + if ((isBetween(n, 3, 10) || isBetween(n, 13, 19))) + return 'few'; + if (isIn(n, [2, 12])) + return 'two'; + if (isIn(n, [1, 11])) + return 'one'; + return 'other'; + } + }; + + // return a function that gives the plural form name for a given integer + var index = locales2rules[lang.replace(/-.*$/, '')]; + if (!(index in pluralRules)) { + console.warn('plural form unknown for [' + lang + ']'); + return function() { return 'other'; }; + } + return pluralRules[index]; + } + + // pre-defined 'plural' macro + gMacros.plural = function(str, param, key, prop) { + var n = parseFloat(param); + if (isNaN(n)) + return str; + + // TODO: support other properties (l20n still doesn't...) + if (prop != gTextProp) + return str; + + // initialize _pluralRules + if (!gMacros._pluralRules) { + gMacros._pluralRules = getPluralRules(gLanguage); + } + var index = '[' + gMacros._pluralRules(n) + ']'; + + // try to find a [zero|one|two] key if it's defined + if (n === 0 && (key + '[zero]') in gL10nData) { + str = gL10nData[key + '[zero]'][prop]; + } else if (n == 1 && (key + '[one]') in gL10nData) { + str = gL10nData[key + '[one]'][prop]; + } else if (n == 2 && (key + '[two]') in gL10nData) { + str = gL10nData[key + '[two]'][prop]; + } else if ((key + index) in gL10nData) { + str = gL10nData[key + index][prop]; + } else if ((key + '[other]') in gL10nData) { + str = gL10nData[key + '[other]'][prop]; + } + + return str; + }; + + + /** + * l10n dictionary functions + */ + + // fetch an l10n object, warn if not found, apply `args' if possible + function getL10nData(key, args, fallback) { + var data = gL10nData[key]; + if (!data) { + console.warn('#' + key + ' is undefined.'); + if (!fallback) { + return null; + } + data = fallback; + } + + /** This is where l10n expressions should be processed. + * The plan is to support C-style expressions from the l20n project; + * until then, only two kinds of simple expressions are supported: + * {[ index ]} and {{ arguments }}. + */ + var rv = {}; + for (var prop in data) { + var str = data[prop]; + str = substIndexes(str, args, key, prop); + str = substArguments(str, args, key); + rv[prop] = str; + } + return rv; + } + + // replace {[macros]} with their values + function substIndexes(str, args, key, prop) { + var reIndex = /\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/; + var reMatch = reIndex.exec(str); + if (!reMatch || !reMatch.length) + return str; + + // an index/macro has been found + // Note: at the moment, only one parameter is supported + var macroName = reMatch[1]; + var paramName = reMatch[2]; + var param; + if (args && paramName in args) { + param = args[paramName]; + } else if (paramName in gL10nData) { + param = gL10nData[paramName]; + } + + // there's no macro parser yet: it has to be defined in gMacros + if (macroName in gMacros) { + var macro = gMacros[macroName]; + str = macro(str, param, key, prop); + } + return str; + } + + // replace {{arguments}} with their values + function substArguments(str, args, key) { + var reArgs = /\{\{\s*(.+?)\s*\}\}/g; + return str.replace(reArgs, function(matched_text, arg) { + if (args && arg in args) { + return args[arg]; + } + if (arg in gL10nData) { + return gL10nData[arg]; + } + console.log('argument {{' + arg + '}} for #' + key + ' is undefined.'); + return matched_text; + }); + } + + // translate an HTML element + function translateElement(element) { + var l10n = getL10nAttributes(element); + if (!l10n.id) + return; + + // get the related l10n object + var data = getL10nData(l10n.id, l10n.args); + if (!data) { + console.warn('#' + l10n.id + ' is undefined.'); + return; + } + + // translate element (TODO: security checks?) + if (data[gTextProp]) { // XXX + if (getChildElementCount(element) === 0) { + element[gTextProp] = data[gTextProp]; + } else { + // this element has element children: replace the content of the first + // (non-empty) child textNode and clear other child textNodes + var children = element.childNodes; + var found = false; + for (var i = 0, l = children.length; i < l; i++) { + if (children[i].nodeType === 3 && /\S/.test(children[i].nodeValue)) { + if (found) { + children[i].nodeValue = ''; + } else { + children[i].nodeValue = data[gTextProp]; + found = true; + } + } + } + // if no (non-empty) textNode is found, insert a textNode before the + // first element child. + if (!found) { + var textNode = document.createTextNode(data[gTextProp]); + element.insertBefore(textNode, element.firstChild); + } + } + delete data[gTextProp]; + } + + for (var k in data) { + element[k] = data[k]; + } + } + + // webkit browsers don't currently support 'children' on SVG elements... + function getChildElementCount(element) { + if (element.children) { + return element.children.length; + } + if (typeof element.childElementCount !== 'undefined') { + return element.childElementCount; + } + var count = 0; + for (var i = 0; i < element.childNodes.length; i++) { + count += element.nodeType === 1 ? 1 : 0; + } + return count; + } + + // translate an HTML subtree + function translateFragment(element) { + element = element || document.documentElement; + + // check all translatable children (= w/ a `data-l10n-id' attribute) + var children = getTranslatableChildren(element); + var elementCount = children.length; + for (var i = 0; i < elementCount; i++) { + translateElement(children[i]); + } + + // translate element itself if necessary + translateElement(element); + } + + return { + // get a localized string + get: function(key, args, fallbackString) { + var index = key.lastIndexOf('.'); + var prop = gTextProp; + if (index > 0) { // An attribute has been specified + prop = key.substr(index + 1); + key = key.substring(0, index); + } + var fallback; + if (fallbackString) { + fallback = {}; + fallback[prop] = fallbackString; + } + var data = getL10nData(key, args, fallback); + if (data && prop in data) { + return data[prop]; + } + return '{{' + key + '}}'; + }, + + // debug + getData: function() { return gL10nData; }, + getText: function() { return gTextData; }, + + // get|set the document language + getLanguage: function() { return gLanguage; }, + setLanguage: function(lang, callback) { + loadLocale(lang, function() { + if (callback) + callback(); + translateFragment(); + }); + }, + + // get the direction (ltr|rtl) of the current language + getDirection: function() { + // http://www.w3.org/International/questions/qa-scripts + // Arabic, Hebrew, Farsi, Pashto, Urdu + var rtlList = ['ar', 'he', 'fa', 'ps', 'ur']; + var shortCode = gLanguage.split('-', 1)[0]; + return (rtlList.indexOf(shortCode) >= 0) ? 'rtl' : 'ltr'; + }, + + // translate an element or document fragment + translate: translateFragment, + + // this can be used to prevent race conditions + getReadyState: function() { return gReadyState; }, + ready: function(callback) { + if (!callback) { + return; + } else if (gReadyState == 'complete' || gReadyState == 'interactive') { + window.setTimeout(function() { + callback(); + }); + } else if (document.addEventListener) { + document.addEventListener('localized', function once() { + document.removeEventListener('localized', once); + callback(); + }); + } + } + }; +}) (window, document); |
