@rindo/core 1.8.12 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +27 -27
- package/bin/cli.ts +20 -0
- package/bin/rindo +51 -22
- package/cli/index.cjs +1263 -0
- package/cli/index.d.ts +15 -0
- package/cli/index.js +1237 -0
- package/cli/package.json +14 -0
- package/compiler/lib.d.ts +24 -0
- package/compiler/lib.dom.d.ts +20230 -0
- package/compiler/lib.dom.iterable.d.ts +351 -0
- package/compiler/lib.es2015.collection.d.ts +89 -0
- package/compiler/lib.es2015.core.d.ts +517 -0
- package/compiler/lib.es2015.d.ts +30 -0
- package/compiler/lib.es2015.generator.d.ts +79 -0
- package/compiler/lib.es2015.iterable.d.ts +505 -0
- package/compiler/lib.es2015.promise.d.ts +150 -0
- package/compiler/lib.es2015.proxy.d.ts +41 -0
- package/compiler/lib.es2015.reflect.d.ts +123 -0
- package/compiler/lib.es2015.symbol.d.ts +48 -0
- package/compiler/lib.es2015.symbol.wellknown.d.ts +324 -0
- package/compiler/lib.es2016.array.include.d.ts +118 -0
- package/compiler/lib.es2016.d.ts +22 -0
- package/compiler/lib.es2016.full.d.ts +25 -0
- package/compiler/lib.es2017.d.ts +26 -0
- package/compiler/lib.es2017.full.d.ts +25 -0
- package/compiler/lib.es2017.intl.d.ts +32 -0
- package/compiler/lib.es2017.object.d.ts +51 -0
- package/compiler/lib.es2017.sharedmemory.d.ts +137 -0
- package/compiler/lib.es2017.string.d.ts +47 -0
- package/compiler/lib.es2017.typedarrays.d.ts +55 -0
- package/compiler/lib.es2018.asyncgenerator.d.ts +79 -0
- package/compiler/lib.es2018.asynciterable.d.ts +45 -0
- package/compiler/lib.es2018.d.ts +26 -0
- package/compiler/lib.es2018.full.d.ts +25 -0
- package/compiler/lib.es2018.intl.d.ts +61 -0
- package/compiler/lib.es2018.promise.d.ts +32 -0
- package/compiler/lib.es2018.regexp.d.ts +39 -0
- package/compiler/lib.es2019.array.d.ts +85 -0
- package/compiler/lib.es2019.d.ts +25 -0
- package/compiler/lib.es2019.full.d.ts +25 -0
- package/compiler/lib.es2019.object.d.ts +35 -0
- package/compiler/lib.es2019.string.d.ts +33 -0
- package/compiler/lib.es2019.symbol.d.ts +26 -0
- package/compiler/lib.es2020.bigint.d.ts +728 -0
- package/compiler/lib.es2020.d.ts +27 -0
- package/compiler/lib.es2020.full.d.ts +25 -0
- package/compiler/lib.es2020.intl.d.ts +310 -0
- package/compiler/lib.es2020.promise.d.ts +50 -0
- package/compiler/lib.es2020.sharedmemory.d.ts +99 -0
- package/compiler/lib.es2020.string.d.ts +30 -0
- package/compiler/lib.es2020.symbol.wellknown.d.ts +39 -0
- package/compiler/lib.es5.d.ts +4435 -0
- package/compiler/lib.es6.d.ts +25 -0
- package/compiler/lib.esnext.d.ts +25 -0
- package/compiler/lib.esnext.full.d.ts +25 -0
- package/compiler/lib.esnext.intl.d.ts +32 -0
- package/compiler/lib.esnext.promise.d.ts +43 -0
- package/compiler/lib.esnext.string.d.ts +35 -0
- package/compiler/lib.esnext.weakref.d.ts +75 -0
- package/compiler/lib.scripthost.d.ts +327 -0
- package/compiler/lib.webworker.d.ts +6042 -0
- package/compiler/lib.webworker.importscripts.d.ts +26 -0
- package/compiler/lib.webworker.iterable.d.ts +166 -0
- package/compiler/package.json +8 -6
- package/compiler/rindo.d.ts +95 -0
- package/compiler/rindo.js +65051 -6657
- package/compiler/rindo.min.js +4 -0
- package/dependencies.json +103 -0
- package/dev-server/client/app-error.d.ts +18 -0
- package/dev-server/client/events.d.ts +6 -0
- package/dev-server/client/hmr-components.d.ts +1 -0
- package/dev-server/client/hmr-external-styles.d.ts +1 -0
- package/dev-server/client/hmr-images.d.ts +1 -0
- package/dev-server/client/hmr-inline-styles.d.ts +1 -0
- package/dev-server/client/hmr-util.d.ts +9 -0
- package/dev-server/client/hmr-window.d.ts +10 -0
- package/dev-server/client/index.d.ts +6 -0
- package/dev-server/client/index.js +808 -0
- package/dev-server/client/logger.d.ts +5 -0
- package/dev-server/client/package.json +8 -0
- package/dev-server/client/progress.d.ts +3 -0
- package/dev-server/client/status.d.ts +4 -0
- package/dev-server/connector.html +6 -0
- package/dev-server/index.d.ts +3 -0
- package/dev-server/index.js +264 -0
- package/dev-server/open-in-editor-api.js +1 -0
- package/dev-server/package.json +8 -0
- package/dev-server/server-process.js +1738 -0
- package/dev-server/server-worker-thread.js +39 -0
- package/{dist/dev-server → dev-server}/templates/directory-index.html +132 -132
- package/{dist/dev-server → dev-server}/templates/initial-load.html +160 -160
- package/dev-server/ws.js +1 -0
- package/internal/app-data/index.cjs +90 -0
- package/internal/app-data/index.d.ts +4 -0
- package/internal/{client/build-conditionals.mjs → app-data/index.js} +25 -21
- package/internal/app-data/package.json +15 -0
- package/internal/client/css-shim.js +4 -0
- package/internal/client/{dom.rindo-client.mjs → dom.js} +73 -137
- package/{dist/client/index.mjs → internal/client/index.js} +863 -789
- package/internal/client/package.json +8 -0
- package/internal/client/patch-browser.js +120 -0
- package/internal/client/patch-esm.js +23 -0
- package/internal/client/polyfills/core-js.js +11 -10
- package/internal/client/polyfills/css-shim.js +1 -656
- package/internal/client/polyfills/dom.js +79 -146
- package/internal/client/polyfills/es5-html-element.js +1 -18
- package/internal/client/polyfills/index.js +34 -35
- package/internal/client/{shadow-css.rindo-client.mjs → shadow-css.js} +20 -17
- package/internal/hydrate/index.js +1097 -0
- package/internal/hydrate/package.json +7 -0
- package/internal/hydrate/runner.d.ts +217 -0
- package/internal/hydrate/runner.js +777 -0
- package/internal/hydrate/shadow-css.js +146 -0
- package/internal/index.d.ts +4 -18
- package/internal/index.js +1 -1
- package/internal/package.json +9 -6
- package/internal/rindo-core/index.cjs +1 -0
- package/internal/rindo-core/index.d.ts +51 -0
- package/internal/rindo-core/index.js +15 -0
- package/internal/rindo-ext-modules.d.ts +41 -0
- package/internal/rindo-private.d.ts +2128 -0
- package/internal/rindo-public-compiler.d.ts +2170 -0
- package/{dist/declarations/docs.d.ts → internal/rindo-public-docs.d.ts} +13 -1
- package/internal/rindo-public-runtime.d.ts +1555 -0
- package/internal/testing/index.js +1055 -0
- package/internal/testing/package.json +7 -0
- package/internal/testing/shadow-css.js +146 -0
- package/mock-doc/index.cjs +4610 -0
- package/mock-doc/index.d.ts +916 -0
- package/mock-doc/index.js +4574 -2
- package/mock-doc/package.json +15 -10
- package/package.json +132 -186
- package/readme.md +21 -174
- package/screenshot/compare/build/app.css +1 -1
- package/screenshot/compare/build/app.esm.js +1 -1
- package/screenshot/compare/build/app.js +33 -818
- package/screenshot/compare/build/{p-113f7459.js → p-081b0641.js} +1 -1
- package/screenshot/compare/build/p-227a1e18.entry.js +1 -0
- package/screenshot/compare/build/p-2c298727.entry.js +1 -0
- package/screenshot/compare/build/p-5479268c.entry.js +1 -0
- package/screenshot/compare/build/p-573ec8a4.entry.js +1 -0
- package/screenshot/compare/build/p-6ba08604.entry.js +1 -0
- package/screenshot/compare/build/p-6bc63295.entry.js +1 -0
- package/screenshot/compare/build/p-7a3759fd.entry.js +1 -0
- package/screenshot/compare/build/{p-ejpsp3kx.js → p-7b4e3ba7.js} +1 -1
- package/screenshot/compare/build/p-988eb362.css +1 -0
- package/screenshot/compare/build/p-9b6a9315.js +1 -0
- package/screenshot/compare/build/p-b4cc611c.entry.js +1 -0
- package/screenshot/compare/build/p-d1bf53f5.entry.js +1 -0
- package/screenshot/compare/build/{p-efb0eac6.js → p-e2efe0df.js} +1 -1
- package/screenshot/compare/build/p-e8ca6d97.entry.js +1 -0
- package/screenshot/compare/build/p-ec2f13e0.entry.js +1 -0
- package/screenshot/compare/build/p-f0b99977.entry.js +1 -0
- package/screenshot/compare/build/p-f4745c2f.entry.js +1 -0
- package/screenshot/compare/build/p-fbbae598.js +1 -0
- package/screenshot/compare/host.config.json +14 -14
- package/screenshot/compare/index.html +1 -1
- package/{dist/screenshot → screenshot}/connector-base.d.ts +1 -1
- package/{dist/screenshot → screenshot}/connector-local.d.ts +1 -1
- package/screenshot/connector.js +2 -3
- package/{dist/screenshot → screenshot}/index.d.ts +1 -1
- package/screenshot/index.js +659 -2
- package/screenshot/local-connector.js +2 -3
- package/screenshot/package.json +15 -13
- package/screenshot/pixel-match.js +62 -49
- package/screenshot/screenshot-compare.d.ts +3 -0
- package/{dist/screenshot → screenshot}/screenshot-fs.d.ts +1 -1
- package/sys/deno/index.js +1785 -0
- package/sys/deno/node-compat.js +2654 -0
- package/sys/deno/worker.js +44 -0
- package/sys/node/autoprefixer.js +8 -0
- package/sys/node/glob.js +1 -0
- package/sys/node/graceful-fs.js +1 -0
- package/sys/node/index.d.ts +18 -0
- package/sys/node/index.js +1386 -2
- package/sys/node/node-fetch.js +1 -0
- package/sys/node/package.json +8 -5
- package/sys/node/prompts.js +1 -0
- package/sys/node/worker.js +52 -0
- package/{dist/testing → testing}/index.d.ts +5 -6
- package/testing/index.js +4017 -2
- package/testing/jest/jest-config.d.ts +5 -0
- package/{dist/testing → testing}/jest/jest-environment.d.ts +4 -2
- package/{dist/testing → testing}/jest/jest-preprocessor.d.ts +1 -0
- package/{dist/testing → testing}/jest/jest-runner.d.ts +1 -1
- package/{dist/testing → testing}/jest/jest-screenshot.d.ts +1 -1
- package/{dist/testing → testing}/jest/jest-serializer.d.ts +1 -1
- package/testing/jest-environment.js +3 -3
- package/testing/jest-preprocessor.js +3 -3
- package/testing/jest-preset.js +32 -40
- package/testing/jest-runner.js +3 -3
- package/testing/jest-setuptestframework.js +3 -3
- package/{dist/testing → testing}/matchers/events.d.ts +9 -1
- package/{dist/testing → testing}/matchers/index.d.ts +3 -1
- package/{dist/testing → testing}/matchers/screenshot.d.ts +1 -1
- package/testing/mock-fetch.d.ts +11 -0
- package/testing/mocks.d.ts +14 -0
- package/testing/package.json +8 -6
- package/testing/puppeteer/index.d.ts +2 -0
- package/{dist/testing → testing}/puppeteer/puppeteer-browser.d.ts +3 -3
- package/{dist/testing → testing}/puppeteer/puppeteer-declarations.d.ts +18 -18
- package/{dist/testing → testing}/puppeteer/puppeteer-element.d.ts +7 -5
- package/testing/puppeteer/puppeteer-emulate.d.ts +2 -0
- package/{dist/testing → testing}/puppeteer/puppeteer-events.d.ts +9 -9
- package/testing/puppeteer/puppeteer-page.d.ts +2 -0
- package/testing/puppeteer/puppeteer-screenshot.d.ts +4 -0
- package/testing/reset-build-conditionals.d.ts +2 -0
- package/testing/spec-page.d.ts +2 -0
- package/testing/test-transpile.d.ts +2 -0
- package/{dist/testing → testing}/testing-logger.d.ts +10 -8
- package/testing/testing-sys.d.ts +1 -0
- package/{dist/testing → testing}/testing-utils.d.ts +3 -2
- package/testing/testing.d.ts +2 -0
- package/build-conditionals/index.d.ts +0 -2
- package/build-conditionals/index.mjs +0 -66
- package/build-conditionals/package.json +0 -6
- package/compiler/index.js +0 -2
- package/dist/cli/index.js +0 -6068
- package/dist/client/css-shim-14a9812e.js +0 -656
- package/dist/client/css-shim-69821662.js +0 -658
- package/dist/client/declarations/rindo.core.d.ts +0 -1347
- package/dist/client/dom-68c8fe31.js +0 -139
- package/dist/client/dom-af01458a.js +0 -137
- package/dist/client/index.js +0 -2937
- package/dist/client/polyfills/core-js.js +0 -10
- package/dist/client/polyfills/css-shim.js +0 -656
- package/dist/client/polyfills/dom.js +0 -146
- package/dist/client/polyfills/es5-html-element.js +0 -18
- package/dist/client/polyfills/index.js +0 -35
- package/dist/client/polyfills/promise.js +0 -9
- package/dist/client/polyfills/system.js +0 -6
- package/dist/client/shadow-css-6ef31c68.js +0 -386
- package/dist/client/shadow-css-8fd1a9e4.js +0 -388
- package/dist/compiler/app-core/app-es5-disabled.d.ts +0 -2
- package/dist/compiler/app-core/app-polyfills.d.ts +0 -3
- package/dist/compiler/app-core/build-conditionals.d.ts +0 -6
- package/dist/compiler/app-core/bundle-app-core.d.ts +0 -6
- package/dist/compiler/app-core/component-styles.d.ts +0 -4
- package/dist/compiler/app-core/format-component-runtime-meta.d.ts +0 -4
- package/dist/compiler/app-core/optimize-module.d.ts +0 -7
- package/dist/compiler/browser/build-conditionals-client.d.ts +0 -3
- package/dist/compiler/browser/compile-options.d.ts +0 -12
- package/dist/compiler/browser/compile.d.ts +0 -2
- package/dist/compiler/browser/create-compiler.d.ts +0 -14
- package/dist/compiler/browser/index.d.ts +0 -11
- package/dist/compiler/build/build-ctx.d.ts +0 -74
- package/dist/compiler/build/build-finish.d.ts +0 -3
- package/dist/compiler/build/build-hmr.d.ts +0 -2
- package/dist/compiler/build/build-results.d.ts +0 -2
- package/dist/compiler/build/build-stats.d.ts +0 -3
- package/dist/compiler/build/build.d.ts +0 -2
- package/dist/compiler/build/cache-stats.d.ts +0 -4
- package/dist/compiler/build/compiler-build-id.d.ts +0 -6
- package/dist/compiler/build/compiler-ctx.d.ts +0 -44
- package/dist/compiler/build/init-index-html.d.ts +0 -2
- package/dist/compiler/build/validate-files.d.ts +0 -2
- package/dist/compiler/build/write-build.d.ts +0 -2
- package/dist/compiler/cache.d.ts +0 -22
- package/dist/compiler/compiler.d.ts +0 -27
- package/dist/compiler/component-hydrate/bundle-hydrate-factory.d.ts +0 -3
- package/dist/compiler/component-hydrate/generate-hydrate-app.d.ts +0 -2
- package/dist/compiler/component-hydrate/hydrate-factory-closure.d.ts +0 -2
- package/dist/compiler/component-hydrate/update-to-hydrate-components.d.ts +0 -2
- package/dist/compiler/component-hydrate/write-hydrate-outputs.d.ts +0 -3
- package/dist/compiler/component-lazy/generate-cjs.d.ts +0 -3
- package/dist/compiler/component-lazy/generate-esm-browser.d.ts +0 -3
- package/dist/compiler/component-lazy/generate-esm.d.ts +0 -3
- package/dist/compiler/component-lazy/generate-lazy-app.d.ts +0 -3
- package/dist/compiler/component-lazy/generate-lazy-module.d.ts +0 -4
- package/dist/compiler/component-lazy/generate-system.d.ts +0 -3
- package/dist/compiler/component-lazy/update-to-lazy-component.d.ts +0 -2
- package/dist/compiler/component-lazy/write-lazy-entry-module.d.ts +0 -2
- package/dist/compiler/component-native/update-to-native-component.d.ts +0 -2
- package/dist/compiler/config/config-reload.d.ts +0 -3
- package/dist/compiler/config/config-utils.d.ts +0 -4
- package/dist/compiler/config/validate-config.d.ts +0 -4
- package/dist/compiler/config/validate-copy.d.ts +0 -2
- package/dist/compiler/config/validate-dev-server.d.ts +0 -2
- package/dist/compiler/config/validate-docs.d.ts +0 -2
- package/dist/compiler/config/validate-namespace.d.ts +0 -3
- package/dist/compiler/config/validate-output-stats.d.ts +0 -2
- package/dist/compiler/config/validate-outputs-angular.d.ts +0 -2
- package/dist/compiler/config/validate-outputs-custom.d.ts +0 -2
- package/dist/compiler/config/validate-outputs-dist-module.d.ts +0 -2
- package/dist/compiler/config/validate-outputs-dist.d.ts +0 -2
- package/dist/compiler/config/validate-outputs-hydrate-script.d.ts +0 -2
- package/dist/compiler/config/validate-outputs-www.d.ts +0 -2
- package/dist/compiler/config/validate-outputs.d.ts +0 -2
- package/dist/compiler/config/validate-paths.d.ts +0 -2
- package/dist/compiler/config/validate-plugins.d.ts +0 -2
- package/dist/compiler/config/validate-prerender.d.ts +0 -2
- package/dist/compiler/config/validate-rollup-config.d.ts +0 -2
- package/dist/compiler/config/validate-service-worker.d.ts +0 -2
- package/dist/compiler/config/validate-testing.d.ts +0 -2
- package/dist/compiler/config/validate-workers.d.ts +0 -2
- package/dist/compiler/copy/assets-copy-tasks.d.ts +0 -3
- package/dist/compiler/copy/hashed-copy.d.ts +0 -2
- package/dist/compiler/copy/local-copy-tasks.d.ts +0 -3
- package/dist/compiler/docs/constants.d.ts +0 -2
- package/dist/compiler/docs/custom/index.d.ts +0 -2
- package/dist/compiler/docs/docs.d.ts +0 -2
- package/dist/compiler/docs/generate-doc-data.d.ts +0 -3
- package/dist/compiler/docs/json/index.d.ts +0 -3
- package/dist/compiler/docs/readme/docs-util.d.ts +0 -13
- package/dist/compiler/docs/readme/index.d.ts +0 -3
- package/dist/compiler/docs/readme/markdown-css-props.d.ts +0 -2
- package/dist/compiler/docs/readme/markdown-dependencies.d.ts +0 -2
- package/dist/compiler/docs/readme/markdown-events.d.ts +0 -2
- package/dist/compiler/docs/readme/markdown-methods.d.ts +0 -2
- package/dist/compiler/docs/readme/markdown-props.d.ts +0 -2
- package/dist/compiler/docs/readme/markdown-slots.d.ts +0 -2
- package/dist/compiler/docs/readme/markdown-usage.d.ts +0 -6
- package/dist/compiler/docs/readme/output-docs.d.ts +0 -3
- package/dist/compiler/docs/style-docs.d.ts +0 -2
- package/dist/compiler/docs/vscode/index.d.ts +0 -2
- package/dist/compiler/entries/component-bundles.d.ts +0 -3
- package/dist/compiler/entries/component-graph.d.ts +0 -2
- package/dist/compiler/entries/default-bundles.d.ts +0 -3
- package/dist/compiler/entries/entry-modules.d.ts +0 -6
- package/dist/compiler/entries/resolve-component-dependencies.d.ts +0 -2
- package/dist/compiler/events.d.ts +0 -15
- package/dist/compiler/fs-watch/fs-watch-init.d.ts +0 -2
- package/dist/compiler/fs-watch/fs-watch-log.d.ts +0 -2
- package/dist/compiler/fs-watch/fs-watch-rebuild.d.ts +0 -7
- package/dist/compiler/html/inject-module-preloads.d.ts +0 -3
- package/dist/compiler/html/inject-sw-script.d.ts +0 -4
- package/dist/compiler/html/inline-esm-import.d.ts +0 -2
- package/dist/compiler/html/inline-style-sheets.d.ts +0 -2
- package/dist/compiler/html/update-global-styles-link.d.ts +0 -2
- package/dist/compiler/html/used-components.d.ts +0 -2
- package/dist/compiler/html/utils.d.ts +0 -2
- package/dist/compiler/html/validate-manifest-json.d.ts +0 -2
- package/dist/compiler/index.d.ts +0 -10
- package/dist/compiler/index.js +0 -18008
- package/dist/compiler/output-targets/empty-dir.d.ts +0 -6
- package/dist/compiler/output-targets/index.d.ts +0 -2
- package/dist/compiler/output-targets/output-angular.d.ts +0 -4
- package/dist/compiler/output-targets/output-app.d.ts +0 -4
- package/dist/compiler/output-targets/output-collection.d.ts +0 -3
- package/dist/compiler/output-targets/output-copy.d.ts +0 -2
- package/dist/compiler/output-targets/output-custom.d.ts +0 -2
- package/dist/compiler/output-targets/output-docs.d.ts +0 -2
- package/dist/compiler/output-targets/output-hydrate.d.ts +0 -2
- package/dist/compiler/output-targets/output-lazy-loader.d.ts +0 -2
- package/dist/compiler/output-targets/output-module.d.ts +0 -4
- package/dist/compiler/output-targets/output-prerender.d.ts +0 -2
- package/dist/compiler/output-targets/output-service-workers.d.ts +0 -2
- package/dist/compiler/output-targets/output-types.d.ts +0 -2
- package/dist/compiler/output-targets/output-utils.d.ts +0 -54
- package/dist/compiler/output-targets/output-www.d.ts +0 -2
- package/dist/compiler/plugin/plugin.d.ts +0 -6
- package/dist/compiler/prerender/crawl-urls.d.ts +0 -3
- package/dist/compiler/prerender/host-config.d.ts +0 -12
- package/dist/compiler/prerender/prerender-config.d.ts +0 -2
- package/dist/compiler/prerender/prerender-main.d.ts +0 -2
- package/dist/compiler/prerender/prerender-queue.d.ts +0 -3
- package/dist/compiler/prerender/prerender-template-html.d.ts +0 -2
- package/dist/compiler/prerender/prerendered-write-path.d.ts +0 -2
- package/dist/compiler/prerender/robots-txt.d.ts +0 -2
- package/dist/compiler/prerender/sitemap-xml.d.ts +0 -3
- package/dist/compiler/rollup-plugins/component-entry.d.ts +0 -3
- package/dist/compiler/rollup-plugins/css-transformer.d.ts +0 -3
- package/dist/compiler/rollup-plugins/global-scripts.d.ts +0 -4
- package/dist/compiler/rollup-plugins/image-plugin.d.ts +0 -3
- package/dist/compiler/rollup-plugins/in-memory-fs-read.d.ts +0 -3
- package/dist/compiler/rollup-plugins/loader.d.ts +0 -4
- package/dist/compiler/rollup-plugins/plugin-helper.d.ts +0 -5
- package/dist/compiler/rollup-plugins/rindo-build-conditionals.d.ts +0 -7
- package/dist/compiler/rollup-plugins/rindo-client.d.ts +0 -3
- package/dist/compiler/rollup-plugins/rindo-external-runtime.d.ts +0 -2
- package/dist/compiler/rollup-plugins/rindo-hydrate.d.ts +0 -3
- package/dist/compiler/rollup-plugins/rindo-public-plugin.d.ts +0 -2
- package/dist/compiler/service-worker/generate-sw.d.ts +0 -7
- package/dist/compiler/service-worker/service-worker-util.d.ts +0 -2
- package/dist/compiler/style/cached-styles.d.ts +0 -5
- package/dist/compiler/style/component-styles.d.ts +0 -2
- package/dist/compiler/style/css-imports.d.ts +0 -9
- package/dist/compiler/style/css-to-esm.d.ts +0 -5
- package/dist/compiler/style/generate-styles.d.ts +0 -2
- package/dist/compiler/style/global-styles.d.ts +0 -3
- package/dist/compiler/style/normalize-styles.d.ts +0 -2
- package/dist/compiler/style/optimize-css.d.ts +0 -2
- package/dist/compiler/style/scope-css.d.ts +0 -3
- package/dist/compiler/style/style-utils.d.ts +0 -10
- package/dist/compiler/transformers/add-component-meta-proxy.d.ts +0 -3
- package/dist/compiler/transformers/add-component-meta-static.d.ts +0 -4
- package/dist/compiler/transformers/add-imports.d.ts +0 -3
- package/dist/compiler/transformers/collections/add-external-import.d.ts +0 -2
- package/dist/compiler/transformers/collections/parse-collection-components.d.ts +0 -2
- package/dist/compiler/transformers/collections/parse-collection-deprecated.d.ts +0 -2
- package/dist/compiler/transformers/collections/parse-collection-manifest.d.ts +0 -7
- package/dist/compiler/transformers/collections/parse-collection-module.d.ts +0 -2
- package/dist/compiler/transformers/component-build-conditionals.d.ts +0 -2
- package/dist/compiler/transformers/component-hydrate/hydrate-component.d.ts +0 -3
- package/dist/compiler/transformers/component-hydrate/hydrate-runtime-cmp-meta.d.ts +0 -3
- package/dist/compiler/transformers/component-hydrate/tranform-to-hydrate-component.d.ts +0 -2
- package/dist/compiler/transformers/component-lazy/lazy-component.d.ts +0 -3
- package/dist/compiler/transformers/component-lazy/lazy-constructor.d.ts +0 -3
- package/dist/compiler/transformers/component-lazy/lazy-element-getter.d.ts +0 -3
- package/dist/compiler/transformers/component-lazy/transform-lazy-component.d.ts +0 -4
- package/dist/compiler/transformers/component-native/native-component.d.ts +0 -3
- package/dist/compiler/transformers/component-native/native-connected-callback.d.ts +0 -3
- package/dist/compiler/transformers/component-native/native-constructor.d.ts +0 -3
- package/dist/compiler/transformers/component-native/native-element-getter.d.ts +0 -3
- package/dist/compiler/transformers/component-native/native-static-style.d.ts +0 -3
- package/dist/compiler/transformers/component-native/tranform-to-native-component.d.ts +0 -4
- package/dist/compiler/transformers/core-runtime-apis.d.ts +0 -30
- package/dist/compiler/transformers/create-event.d.ts +0 -3
- package/dist/compiler/transformers/decorators-to-static/component-decorator.d.ts +0 -3
- package/dist/compiler/transformers/decorators-to-static/convert-decorators.d.ts +0 -3
- package/dist/compiler/transformers/decorators-to-static/decorator-utils.d.ts +0 -10
- package/dist/compiler/transformers/decorators-to-static/element-decorator.d.ts +0 -3
- package/dist/compiler/transformers/decorators-to-static/event-decorator.d.ts +0 -4
- package/dist/compiler/transformers/decorators-to-static/listen-decorator.d.ts +0 -6
- package/dist/compiler/transformers/decorators-to-static/method-decorator.d.ts +0 -3
- package/dist/compiler/transformers/decorators-to-static/prop-decorator.d.ts +0 -4
- package/dist/compiler/transformers/decorators-to-static/state-decorator.d.ts +0 -3
- package/dist/compiler/transformers/decorators-to-static/style-to-static.d.ts +0 -3
- package/dist/compiler/transformers/decorators-to-static/watch-decorator.d.ts +0 -3
- package/dist/compiler/transformers/define-custom-element.d.ts +0 -3
- package/dist/compiler/transformers/host-data-transform.d.ts +0 -3
- package/dist/compiler/transformers/legacy-props.d.ts +0 -3
- package/dist/compiler/transformers/remove-static-meta-properties.d.ts +0 -2
- package/dist/compiler/transformers/reserved-public-members.d.ts +0 -3
- package/dist/compiler/transformers/rindo-import-path.d.ts +0 -3
- package/dist/compiler/transformers/static-to-meta/call-expression.d.ts +0 -3
- package/dist/compiler/transformers/static-to-meta/class-methods.d.ts +0 -3
- package/dist/compiler/transformers/static-to-meta/component.d.ts +0 -3
- package/dist/compiler/transformers/static-to-meta/element-ref.d.ts +0 -2
- package/dist/compiler/transformers/static-to-meta/encapsulation.d.ts +0 -3
- package/dist/compiler/transformers/static-to-meta/events.d.ts +0 -3
- package/dist/compiler/transformers/static-to-meta/import.d.ts +0 -3
- package/dist/compiler/transformers/static-to-meta/listeners.d.ts +0 -3
- package/dist/compiler/transformers/static-to-meta/methods.d.ts +0 -3
- package/dist/compiler/transformers/static-to-meta/props.d.ts +0 -3
- package/dist/compiler/transformers/static-to-meta/states.d.ts +0 -3
- package/dist/compiler/transformers/static-to-meta/string-literal.d.ts +0 -3
- package/dist/compiler/transformers/static-to-meta/styles.d.ts +0 -3
- package/dist/compiler/transformers/static-to-meta/vdom.d.ts +0 -3
- package/dist/compiler/transformers/static-to-meta/visitor.d.ts +0 -3
- package/dist/compiler/transformers/static-to-meta/watchers.d.ts +0 -3
- package/dist/compiler/transformers/style-imports.d.ts +0 -3
- package/dist/compiler/transformers/transform-utils.d.ts +0 -31
- package/dist/compiler/transformers/update-component-class.d.ts +0 -3
- package/dist/compiler/transformers/update-rindo-core-import.d.ts +0 -3
- package/dist/compiler/transformers/watcher-meta-transform.d.ts +0 -3
- package/dist/compiler/transpile/compiler-options.d.ts +0 -4
- package/dist/compiler/transpile/transpile-app.d.ts +0 -2
- package/dist/compiler/transpile/transpile-module.d.ts +0 -5
- package/dist/compiler/transpile/transpile-service.d.ts +0 -3
- package/dist/compiler/transpile/transpile-to-es5-main.d.ts +0 -2
- package/dist/compiler/transpile/validate-types-main.d.ts +0 -2
- package/dist/compiler/types/generate-app-types.d.ts +0 -2
- package/dist/compiler/types/generate-component-types.d.ts +0 -8
- package/dist/compiler/types/generate-event-types.d.ts +0 -2
- package/dist/compiler/types/generate-method-types.d.ts +0 -2
- package/dist/compiler/types/generate-prop-types.d.ts +0 -2
- package/dist/compiler/types/generate-types.d.ts +0 -2
- package/dist/compiler/types/rindo-types.d.ts +0 -3
- package/dist/compiler/types/types-utils.d.ts +0 -4
- package/dist/compiler/types/update-import-refs.d.ts +0 -11
- package/dist/compiler/types/validate-package-json.d.ts +0 -9
- package/dist/declarations/assets.d.ts +0 -17
- package/dist/declarations/browser-compile.d.ts +0 -47
- package/dist/declarations/build-conditionals.d.ts +0 -91
- package/dist/declarations/build-events.d.ts +0 -19
- package/dist/declarations/build.d.ts +0 -247
- package/dist/declarations/cache.d.ts +0 -11
- package/dist/declarations/collection-manifest.d.ts +0 -106
- package/dist/declarations/collection.d.ts +0 -139
- package/dist/declarations/compiler.d.ts +0 -53
- package/dist/declarations/component-compiler-meta.d.ts +0 -198
- package/dist/declarations/component-constructor.d.ts +0 -61
- package/dist/declarations/component-interfaces.d.ts +0 -123
- package/dist/declarations/config.d.ts +0 -409
- package/dist/declarations/css-var-shim.d.ts +0 -9
- package/dist/declarations/decorators.d.ts +0 -150
- package/dist/declarations/dev-server.d.ts +0 -135
- package/dist/declarations/diagnostics.d.ts +0 -21
- package/dist/declarations/entry.d.ts +0 -28
- package/dist/declarations/events.d.ts +0 -13
- package/dist/declarations/file-system.d.ts +0 -91
- package/dist/declarations/fs-watch.d.ts +0 -15
- package/dist/declarations/host-element.d.ts +0 -53
- package/dist/declarations/hydrate.d.ts +0 -99
- package/dist/declarations/in-memory-fs.d.ts +0 -59
- package/dist/declarations/index.d.ts +0 -45
- package/dist/declarations/jsdoc.d.ts +0 -16
- package/dist/declarations/jsx.d.ts +0 -1050
- package/dist/declarations/logger.d.ts +0 -25
- package/dist/declarations/minify-js.d.ts +0 -11
- package/dist/declarations/module.d.ts +0 -35
- package/dist/declarations/optimize-css.d.ts +0 -12
- package/dist/declarations/output-targets.d.ts +0 -189
- package/dist/declarations/plugin.d.ts +0 -23
- package/dist/declarations/prerender.d.ts +0 -79
- package/dist/declarations/render.d.ts +0 -62
- package/dist/declarations/runtime.d.ts +0 -92
- package/dist/declarations/screenshots.d.ts +0 -192
- package/dist/declarations/server.d.ts +0 -19
- package/dist/declarations/style.d.ts +0 -35
- package/dist/declarations/system.d.ts +0 -174
- package/dist/declarations/testing.d.ts +0 -523
- package/dist/declarations/transpile.d.ts +0 -24
- package/dist/declarations/types.d.ts +0 -24
- package/dist/declarations/vdom.d.ts +0 -55
- package/dist/declarations/worker.d.ts +0 -33
- package/dist/dev-server/content-type-db.json +0 -1
- package/dist/dev-server/index.js +0 -887
- package/dist/dev-server/static/app-error.css +0 -257
- package/dist/dev-server/static/dev-server-client.html +0 -13
- package/dist/hydrate/index.d.ts +0 -101
- package/dist/hydrate/index.mjs +0 -1281
- package/dist/hydrate/platform.mjs +0 -347
- package/dist/index.d.ts +0 -99
- package/dist/index.js +0 -1
- package/dist/mock-doc/index.d.ts +0 -851
- package/dist/mock-doc/index.js +0 -3982
- package/dist/mock-doc/index.mjs +0 -3954
- package/dist/runtime/index.js +0 -2576
- package/dist/runtime/index.mjs +0 -2521
- package/dist/runtime/shadow-css-6ef31c68.js +0 -386
- package/dist/runtime/shadow-css-8fd1a9e4.js +0 -388
- package/dist/screenshot/index.js +0 -520
- package/dist/sys/node/graceful-fs.js +0 -975
- package/dist/sys/node/index.js +0 -33545
- package/dist/sys/node/node-fetch.js +0 -1779
- package/dist/sys/node/open-in-editor.js +0 -734
- package/dist/sys/node/sys-worker.js +0 -67035
- package/dist/sys/node/websocket.js +0 -3728
- package/dist/testing/build-conditionals.d.ts +0 -4
- package/dist/testing/build-conditionals.js +0 -43
- package/dist/testing/core.d.ts +0 -35
- package/dist/testing/core.js +0 -52
- package/dist/testing/index.js +0 -40511
- package/dist/testing/jest/jest-config.d.ts +0 -4
- package/dist/testing/mock-fetch.d.ts +0 -46
- package/dist/testing/mocks.d.ts +0 -12
- package/dist/testing/platform.d.ts +0 -23
- package/dist/testing/platform.js +0 -321
- package/dist/testing/puppeteer/puppeteer-emulate.d.ts +0 -2
- package/dist/testing/puppeteer/puppeteer-find.d.ts +0 -5
- package/dist/testing/puppeteer/puppeteer-page.d.ts +0 -2
- package/dist/testing/puppeteer/puppeteer-screenshot.d.ts +0 -4
- package/dist/testing/spec-page.d.ts +0 -5
- package/dist/testing/task-queue.d.ts +0 -15
- package/dist/testing/test-transpile.d.ts +0 -5
- package/dist/testing/testing-fs.d.ts +0 -31
- package/dist/testing/testing-sys.d.ts +0 -19
- package/dist/testing/testing.d.ts +0 -12
- package/dist/utils/index.js +0 -1575
- package/dist/utils/index.mjs +0 -1511
- package/internal/client/css-shim.rindo-client.mjs +0 -656
- package/internal/client/index.mjs +0 -2859
- package/internal/client/polyfills/promise.js +0 -9
- package/internal/images.d.ts +0 -5
- package/runtime/package.json +0 -5
- package/screenshot/compare/build/p-020f8d73.js +0 -1
- package/screenshot/compare/build/p-09qdknbg.system.entry.js +0 -1
- package/screenshot/compare/build/p-0a13mpsc.system.entry.js +0 -1
- package/screenshot/compare/build/p-168ec2c4.system.js +0 -1
- package/screenshot/compare/build/p-2ab1fdf1.system.js +0 -1
- package/screenshot/compare/build/p-2pxcsgrj.entry.js +0 -1
- package/screenshot/compare/build/p-42fb7034.system.js +0 -1
- package/screenshot/compare/build/p-54d9d7c2.system.js +0 -1
- package/screenshot/compare/build/p-67c1f911.js +0 -1
- package/screenshot/compare/build/p-68613371.system.js +0 -1
- package/screenshot/compare/build/p-7dvsjpu0.entry.js +0 -1
- package/screenshot/compare/build/p-aa67fb06.js +0 -1
- package/screenshot/compare/build/p-aeb3cec1.system.js +0 -1
- package/screenshot/compare/build/p-b6e44a24.js +0 -1
- package/screenshot/compare/build/p-c1c25b8a.js +0 -1
- package/screenshot/compare/build/p-c9bopbjy.system.entry.js +0 -1
- package/screenshot/compare/build/p-c9iqz1pp.system.entry.js +0 -1
- package/screenshot/compare/build/p-dizjz8rg.entry.js +0 -1
- package/screenshot/compare/build/p-dnta0rwp.system.entry.js +0 -1
- package/screenshot/compare/build/p-e9670d22.system.js +0 -1
- package/screenshot/compare/build/p-ei9jkpd0.system.entry.js +0 -1
- package/screenshot/compare/build/p-ejwcppol.entry.js +0 -1
- package/screenshot/compare/build/p-f6612d5d.system.js +0 -1
- package/screenshot/compare/build/p-foiivsfc.css +0 -1
- package/screenshot/compare/build/p-gpjjyogx.entry.js +0 -1
- package/screenshot/compare/build/p-howklem2.system.entry.js +0 -1
- package/screenshot/compare/build/p-knv9wvoc.entry.js +0 -1
- package/screenshot/compare/build/p-nsqsfhhy.entry.js +0 -1
- package/screenshot/compare/build/p-ojt278pp.entry.js +0 -1
- package/screenshot/compare/build/p-oywass99.entry.js +0 -1
- package/screenshot/compare/build/p-q3ujhub6.entry.js +0 -1
- package/screenshot/compare/build/p-qw4xnmxv.entry.js +0 -1
- package/screenshot/compare/build/p-t1wvevhc.system.entry.js +0 -1
- package/screenshot/compare/build/p-tnjarrex.system.entry.js +0 -1
- package/screenshot/compare/build/p-vhfpd6kk.system.entry.js +0 -1
- package/screenshot/compare/build/p-vk6rhemd.system.entry.js +0 -1
- package/screenshot/compare/build/p-w6bnm16k.entry.js +0 -1
- package/screenshot/compare/build/p-xje6d7zl.system.entry.js +0 -1
- package/screenshot/compare/build/p-y5jlrcha.system.entry.js +0 -1
- package/screenshot/compare/build/p-yh170wkt.entry.js +0 -1
- package/testing/jest.preprocessor.js +0 -7
- /package/{dist/dev-server → dev-server}/static/favicon.ico +0 -0
- /package/{dist/sys/node → dev-server}/visualstudio.vbs +0 -0
- /package/{dist/sys/node → dev-server}/xdg-open +0 -0
- /package/{dist/compiler/polyfills.d.ts → screenshot/compare/build/index.esm.js} +0 -0
- /package/{dist/screenshot → screenshot}/pixel-match.d.ts +0 -0
- /package/{dist/testing → testing}/jest/jest-setup-test-framework.d.ts +0 -0
- /package/{dist/testing → testing}/matchers/attributes.d.ts +0 -0
- /package/{dist/testing → testing}/matchers/class-list.d.ts +0 -0
- /package/{dist/testing → testing}/matchers/html.d.ts +0 -0
- /package/{dist/testing → testing}/matchers/text.d.ts +0 -0
package/dist/dev-server/index.js
DELETED
|
@@ -1,887 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
4
|
-
|
|
5
|
-
var node = require('../sys/node');
|
|
6
|
-
var utils = require('../utils');
|
|
7
|
-
var path = require('path');
|
|
8
|
-
var path__default = _interopDefault(path);
|
|
9
|
-
var querystring = require('querystring');
|
|
10
|
-
var Url = require('url');
|
|
11
|
-
var zlib = require('zlib');
|
|
12
|
-
var buffer = require('buffer');
|
|
13
|
-
var net = require('net');
|
|
14
|
-
var http = require('http');
|
|
15
|
-
var https = require('https');
|
|
16
|
-
|
|
17
|
-
function sendMsg(process, msg) {
|
|
18
|
-
process.send(msg);
|
|
19
|
-
}
|
|
20
|
-
function sendError(process, e) {
|
|
21
|
-
const msg = {
|
|
22
|
-
error: {
|
|
23
|
-
message: e
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
if (typeof e === 'string') {
|
|
27
|
-
msg.error.message = e + '';
|
|
28
|
-
}
|
|
29
|
-
else if (e) {
|
|
30
|
-
Object.keys(e).forEach(key => {
|
|
31
|
-
try {
|
|
32
|
-
msg.error[key] = e[key] + '';
|
|
33
|
-
}
|
|
34
|
-
catch (idk) {
|
|
35
|
-
console.log(idk);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
sendMsg(process, msg);
|
|
40
|
-
}
|
|
41
|
-
function responseHeaders(headers) {
|
|
42
|
-
return Object.assign({}, DEFAULT_HEADERS, headers);
|
|
43
|
-
}
|
|
44
|
-
const DEFAULT_HEADERS = {
|
|
45
|
-
'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0',
|
|
46
|
-
'Expires': '0',
|
|
47
|
-
'X-Powered-By': 'Rindo Dev Server',
|
|
48
|
-
'Access-Control-Allow-Origin': '*'
|
|
49
|
-
};
|
|
50
|
-
function getBrowserUrl(protocol, address, port, basePath, pathname) {
|
|
51
|
-
address = (address === `0.0.0.0`) ? `localhost` : address;
|
|
52
|
-
const portSuffix = (!port || port === 80 || port === 443) ? '' : (':' + port);
|
|
53
|
-
let path = basePath;
|
|
54
|
-
if (pathname.startsWith('/')) {
|
|
55
|
-
pathname = pathname.substring(1);
|
|
56
|
-
}
|
|
57
|
-
path += pathname;
|
|
58
|
-
protocol = protocol.replace(/\:/g, '');
|
|
59
|
-
return `${protocol}://${address}${portSuffix}${path}`;
|
|
60
|
-
}
|
|
61
|
-
function getDevServerClientUrl(devServerConfig, host) {
|
|
62
|
-
let address = devServerConfig.address;
|
|
63
|
-
let port = devServerConfig.port;
|
|
64
|
-
if (host) {
|
|
65
|
-
address = host;
|
|
66
|
-
port = null;
|
|
67
|
-
}
|
|
68
|
-
return getBrowserUrl(devServerConfig.protocol, address, port, devServerConfig.basePath, DEV_SERVER_URL);
|
|
69
|
-
}
|
|
70
|
-
function getContentType(devServerConfig, filePath) {
|
|
71
|
-
const last = filePath.replace(/^.*[/\\]/, '').toLowerCase();
|
|
72
|
-
const ext = last.replace(/^.*\./, '').toLowerCase();
|
|
73
|
-
const hasPath = last.length < filePath.length;
|
|
74
|
-
const hasDot = ext.length < last.length - 1;
|
|
75
|
-
return ((hasDot || !hasPath) && devServerConfig.contentTypes[ext]) || 'application/octet-stream';
|
|
76
|
-
}
|
|
77
|
-
function isHtmlFile(filePath) {
|
|
78
|
-
filePath = filePath.toLowerCase().trim();
|
|
79
|
-
return (filePath.endsWith('.html') || filePath.endsWith('.htm'));
|
|
80
|
-
}
|
|
81
|
-
function isCssFile(filePath) {
|
|
82
|
-
filePath = filePath.toLowerCase().trim();
|
|
83
|
-
return filePath.endsWith('.css');
|
|
84
|
-
}
|
|
85
|
-
const TXT_EXT = ['css', 'html', 'htm', 'js', 'json', 'svg', 'xml'];
|
|
86
|
-
function isSimpleText(filePath) {
|
|
87
|
-
const ext = filePath.toLowerCase().trim().split('.').pop();
|
|
88
|
-
return TXT_EXT.includes(ext);
|
|
89
|
-
}
|
|
90
|
-
function isDevClient(pathname) {
|
|
91
|
-
return pathname.startsWith(DEV_SERVER_URL);
|
|
92
|
-
}
|
|
93
|
-
function isOpenInEditor(pathname) {
|
|
94
|
-
return pathname === OPEN_IN_EDITOR_URL;
|
|
95
|
-
}
|
|
96
|
-
function isInitialDevServerLoad(pathname) {
|
|
97
|
-
return pathname === DEV_SERVER_INIT_URL;
|
|
98
|
-
}
|
|
99
|
-
function isDevServerClient(pathname) {
|
|
100
|
-
return pathname === DEV_SERVER_URL;
|
|
101
|
-
}
|
|
102
|
-
const DEV_SERVER_URL = '/~dev-server';
|
|
103
|
-
const DEV_SERVER_INIT_URL = `${DEV_SERVER_URL}-init`;
|
|
104
|
-
const OPEN_IN_EDITOR_URL = `${DEV_SERVER_URL}-open-in-editor`;
|
|
105
|
-
function shouldCompress(devServerConfig, req) {
|
|
106
|
-
if (!devServerConfig.gzip) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
if (req.method !== 'GET') {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
const acceptEncoding = req.headers && req.headers['accept-encoding'];
|
|
113
|
-
if (typeof acceptEncoding !== 'string') {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
if (!acceptEncoding.includes('gzip')) {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function serve500(devServerConfig, req, res, error) {
|
|
123
|
-
try {
|
|
124
|
-
res.writeHead(500, responseHeaders({
|
|
125
|
-
'Content-Type': 'text/plain'
|
|
126
|
-
}));
|
|
127
|
-
let errorMsg = '';
|
|
128
|
-
if (typeof error === 'string') {
|
|
129
|
-
errorMsg = error;
|
|
130
|
-
}
|
|
131
|
-
else if (error) {
|
|
132
|
-
if (error.message) {
|
|
133
|
-
errorMsg += error.message + '\n';
|
|
134
|
-
}
|
|
135
|
-
if (error.stack) {
|
|
136
|
-
errorMsg += error.stack + '\n';
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
res.write(errorMsg);
|
|
140
|
-
res.end();
|
|
141
|
-
if (devServerConfig.logRequests) {
|
|
142
|
-
sendMsg(process, {
|
|
143
|
-
requestLog: {
|
|
144
|
-
method: req.method,
|
|
145
|
-
url: req.url,
|
|
146
|
-
status: 200
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
catch (e) {
|
|
152
|
-
sendError(process, 'serve500: ' + e);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
async function serve404(devServerConfig, fs, req, res) {
|
|
157
|
-
try {
|
|
158
|
-
if (req.pathname === '/favicon.ico') {
|
|
159
|
-
try {
|
|
160
|
-
const defaultFavicon = path.join(devServerConfig.devServerDir, 'static', 'favicon.ico');
|
|
161
|
-
res.writeHead(200, responseHeaders({
|
|
162
|
-
'Content-Type': 'image/x-icon'
|
|
163
|
-
}));
|
|
164
|
-
fs.createReadStream(defaultFavicon).pipe(res);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
catch (e) { }
|
|
168
|
-
}
|
|
169
|
-
const content = [
|
|
170
|
-
'404 File Not Found',
|
|
171
|
-
'Url: ' + req.pathname,
|
|
172
|
-
'File: ' + req.filePath
|
|
173
|
-
].join('\n');
|
|
174
|
-
serve404Content(devServerConfig, req, res, content);
|
|
175
|
-
if (devServerConfig.logRequests) {
|
|
176
|
-
sendMsg(process, {
|
|
177
|
-
requestLog: {
|
|
178
|
-
method: req.method,
|
|
179
|
-
url: req.url,
|
|
180
|
-
status: 404
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
catch (e) {
|
|
186
|
-
serve500(devServerConfig, req, res, e);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
function serve404Content(devServerConfig, req, res, content) {
|
|
190
|
-
try {
|
|
191
|
-
const headers = responseHeaders({
|
|
192
|
-
'Content-Type': 'text/plain'
|
|
193
|
-
});
|
|
194
|
-
res.writeHead(404, headers);
|
|
195
|
-
res.write(content);
|
|
196
|
-
res.end();
|
|
197
|
-
}
|
|
198
|
-
catch (e) {
|
|
199
|
-
serve500(devServerConfig, req, res, e);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
async function serveFile(devServerConfig, fs, req, res) {
|
|
204
|
-
try {
|
|
205
|
-
if (isSimpleText(req.filePath)) {
|
|
206
|
-
// easy text file, use the internal cache
|
|
207
|
-
let content = await fs.readFile(req.filePath);
|
|
208
|
-
if (devServerConfig.websocket && isHtmlFile(req.filePath) && !isDevServerClient(req.pathname)) {
|
|
209
|
-
// auto inject our dev server script
|
|
210
|
-
content += getDevServerClientScript(devServerConfig, req);
|
|
211
|
-
}
|
|
212
|
-
else if (isCssFile(req.filePath)) {
|
|
213
|
-
content = updateStyleUrls(req.url, content);
|
|
214
|
-
}
|
|
215
|
-
if (shouldCompress(devServerConfig, req)) {
|
|
216
|
-
// let's gzip this well known web dev text file
|
|
217
|
-
res.writeHead(200, responseHeaders({
|
|
218
|
-
'Content-Type': getContentType(devServerConfig, req.filePath),
|
|
219
|
-
'Content-Encoding': 'gzip',
|
|
220
|
-
'Vary': 'Accept-Encoding'
|
|
221
|
-
}));
|
|
222
|
-
zlib.gzip(content, { level: 9 }, (_, data) => {
|
|
223
|
-
res.end(data);
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
// let's not gzip this file
|
|
228
|
-
res.writeHead(200, responseHeaders({
|
|
229
|
-
'Content-Type': getContentType(devServerConfig, req.filePath),
|
|
230
|
-
'Content-Length': buffer.Buffer.byteLength(content, 'utf8')
|
|
231
|
-
}));
|
|
232
|
-
res.write(content);
|
|
233
|
-
res.end();
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
// non-well-known text file or other file, probably best we use a stream
|
|
238
|
-
// but don't bother trying to gzip this file for the dev server
|
|
239
|
-
res.writeHead(200, responseHeaders({
|
|
240
|
-
'Content-Type': getContentType(devServerConfig, req.filePath),
|
|
241
|
-
'Content-Length': req.stats.size
|
|
242
|
-
}));
|
|
243
|
-
fs.createReadStream(req.filePath).pipe(res);
|
|
244
|
-
}
|
|
245
|
-
if (devServerConfig.logRequests) {
|
|
246
|
-
sendMsg(process, {
|
|
247
|
-
requestLog: {
|
|
248
|
-
method: req.method,
|
|
249
|
-
url: req.url,
|
|
250
|
-
status: 200
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
catch (e) {
|
|
256
|
-
serve500(devServerConfig, req, res, e);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
function updateStyleUrls(cssUrl, oldCss) {
|
|
260
|
-
const parsedUrl = Url.parse(cssUrl);
|
|
261
|
-
const qs = querystring.parse(parsedUrl.query);
|
|
262
|
-
const versionId = qs['s-hmr'];
|
|
263
|
-
const hmrUrls = qs['s-hmr-urls'];
|
|
264
|
-
if (versionId && hmrUrls) {
|
|
265
|
-
hmrUrls.split(',').forEach(hmrUrl => {
|
|
266
|
-
urlVersionIds.set(hmrUrl, versionId);
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
const reg = /url\((['"]?)(.*)\1\)/ig;
|
|
270
|
-
let result;
|
|
271
|
-
let newCss = oldCss;
|
|
272
|
-
while ((result = reg.exec(oldCss)) !== null) {
|
|
273
|
-
const oldUrl = result[2];
|
|
274
|
-
const parsedUrl = Url.parse(oldUrl);
|
|
275
|
-
const fileName = path__default.basename(parsedUrl.pathname);
|
|
276
|
-
const versionId = urlVersionIds.get(fileName);
|
|
277
|
-
if (!versionId) {
|
|
278
|
-
continue;
|
|
279
|
-
}
|
|
280
|
-
const qs = querystring.parse(parsedUrl.query);
|
|
281
|
-
qs['s-hmr'] = versionId;
|
|
282
|
-
parsedUrl.search = querystring.stringify(qs);
|
|
283
|
-
const newUrl = Url.format(parsedUrl);
|
|
284
|
-
newCss = newCss.replace(oldUrl, newUrl);
|
|
285
|
-
}
|
|
286
|
-
return newCss;
|
|
287
|
-
}
|
|
288
|
-
const urlVersionIds = new Map();
|
|
289
|
-
function getDevServerClientScript(devServerConfig, req) {
|
|
290
|
-
const devServerClientUrl = getDevServerClientUrl(devServerConfig, req.host);
|
|
291
|
-
return `\n<iframe title="Rindo Dev Server Connector ⚡" src="${devServerClientUrl}" style="display:block;width:0;height:0;border:0"></iframe>`;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
const openInEditorPath = path.join(__dirname, '..', 'sys', 'node', 'open-in-editor.js');
|
|
295
|
-
async function serveOpenInEditor(devServerConfig, fs, req, res) {
|
|
296
|
-
let status = 200;
|
|
297
|
-
const data = {};
|
|
298
|
-
try {
|
|
299
|
-
if (devServerConfig.editors.length > 0) {
|
|
300
|
-
await parseData(devServerConfig, fs, req, data);
|
|
301
|
-
await openInEditor(data);
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
data.error = `no editors available`;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
catch (e) {
|
|
308
|
-
data.error = e + '';
|
|
309
|
-
status = 500;
|
|
310
|
-
}
|
|
311
|
-
res.writeHead(status, responseHeaders({
|
|
312
|
-
'Content-Type': 'application/json'
|
|
313
|
-
}));
|
|
314
|
-
res.write(JSON.stringify(data, null, 2));
|
|
315
|
-
res.end();
|
|
316
|
-
}
|
|
317
|
-
async function parseData(devServerConfig, fs, req, data) {
|
|
318
|
-
const query = Url.parse(req.url).query;
|
|
319
|
-
const qs = querystring.parse(query);
|
|
320
|
-
if (typeof qs.file !== 'string') {
|
|
321
|
-
data.error = `missing file`;
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
data.file = qs.file;
|
|
325
|
-
if (qs.line != null && !isNaN(qs.line)) {
|
|
326
|
-
data.line = parseInt(qs.line, 10);
|
|
327
|
-
}
|
|
328
|
-
if (typeof data.line !== 'number' || data.line < 1) {
|
|
329
|
-
data.line = 1;
|
|
330
|
-
}
|
|
331
|
-
if (qs.column != null && !isNaN(qs.column)) {
|
|
332
|
-
data.column = parseInt(qs.column, 10);
|
|
333
|
-
}
|
|
334
|
-
if (typeof data.column !== 'number' || data.column < 1) {
|
|
335
|
-
data.column = 1;
|
|
336
|
-
}
|
|
337
|
-
if (typeof qs.editor === 'string') {
|
|
338
|
-
qs.editor = qs.editor.trim().toLowerCase();
|
|
339
|
-
if (devServerConfig.editors.some(e => e.id === qs.editor)) {
|
|
340
|
-
data.editor = qs.editor;
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
343
|
-
data.error = `invalid editor: ${qs.editor}`;
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
else {
|
|
348
|
-
data.editor = devServerConfig.editors[0].id;
|
|
349
|
-
}
|
|
350
|
-
try {
|
|
351
|
-
const stat = await fs.stat(data.file);
|
|
352
|
-
data.exists = stat.isFile();
|
|
353
|
-
}
|
|
354
|
-
catch (e) {
|
|
355
|
-
data.exists = false;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
async function openInEditor(data) {
|
|
359
|
-
if (!data.exists || data.error) {
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
try {
|
|
363
|
-
const opts = {
|
|
364
|
-
editor: data.editor
|
|
365
|
-
};
|
|
366
|
-
const oie = require(openInEditorPath);
|
|
367
|
-
const editor = oie.openInEditor.configure(opts, (err) => data.error = err + '');
|
|
368
|
-
if (data.error) {
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
data.open = `${data.file}:${data.line}:${data.column}`;
|
|
372
|
-
await editor.open(data.open);
|
|
373
|
-
}
|
|
374
|
-
catch (e) {
|
|
375
|
-
data.error = e + '';
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
async function getEditors() {
|
|
379
|
-
const editors = [];
|
|
380
|
-
try {
|
|
381
|
-
const oie = require(openInEditorPath);
|
|
382
|
-
await Promise.all(Object.keys(oie.editors).map(async (id) => {
|
|
383
|
-
const isSupported = await isEditorSupported(oie, id);
|
|
384
|
-
editors.push({
|
|
385
|
-
id: id,
|
|
386
|
-
priority: EDITOR_PRIORITY[id],
|
|
387
|
-
supported: isSupported
|
|
388
|
-
});
|
|
389
|
-
}));
|
|
390
|
-
}
|
|
391
|
-
catch (e) { }
|
|
392
|
-
return editors
|
|
393
|
-
.filter(e => e.supported)
|
|
394
|
-
.sort((a, b) => {
|
|
395
|
-
if (a.priority < b.priority)
|
|
396
|
-
return -1;
|
|
397
|
-
if (a.priority > b.priority)
|
|
398
|
-
return 1;
|
|
399
|
-
return 0;
|
|
400
|
-
}).map(e => {
|
|
401
|
-
return {
|
|
402
|
-
id: e.id,
|
|
403
|
-
name: EDITORS[e.id]
|
|
404
|
-
};
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
async function isEditorSupported(oie, editor) {
|
|
408
|
-
let isSupported = false;
|
|
409
|
-
try {
|
|
410
|
-
await oie.editors[editor].detect();
|
|
411
|
-
isSupported = true;
|
|
412
|
-
}
|
|
413
|
-
catch (e) { }
|
|
414
|
-
return isSupported;
|
|
415
|
-
}
|
|
416
|
-
const EDITORS = {
|
|
417
|
-
atom: 'Atom',
|
|
418
|
-
code: 'Code',
|
|
419
|
-
emacs: 'Emacs',
|
|
420
|
-
idea14ce: 'IDEA 14 Community Edition',
|
|
421
|
-
phpstorm: 'PhpStorm',
|
|
422
|
-
sublime: 'Sublime',
|
|
423
|
-
webstorm: 'WebStorm',
|
|
424
|
-
vim: 'Vim',
|
|
425
|
-
visualstudio: 'Visual Studio',
|
|
426
|
-
};
|
|
427
|
-
const EDITOR_PRIORITY = {
|
|
428
|
-
code: 1,
|
|
429
|
-
atom: 2,
|
|
430
|
-
sublime: 3,
|
|
431
|
-
visualstudio: 4,
|
|
432
|
-
idea14ce: 5,
|
|
433
|
-
webstorm: 6,
|
|
434
|
-
phpstorm: 7,
|
|
435
|
-
vim: 8,
|
|
436
|
-
emacs: 9,
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
async function serveDevClient(devServerConfig, fs, req, res) {
|
|
440
|
-
try {
|
|
441
|
-
if (isOpenInEditor(req.pathname)) {
|
|
442
|
-
return serveOpenInEditor(devServerConfig, fs, req, res);
|
|
443
|
-
}
|
|
444
|
-
if (isDevServerClient(req.pathname)) {
|
|
445
|
-
return serveDevClientScript(devServerConfig, fs, req, res);
|
|
446
|
-
}
|
|
447
|
-
if (isInitialDevServerLoad(req.pathname)) {
|
|
448
|
-
req.filePath = path__default.join(devServerConfig.devServerDir, 'templates', 'initial-load.html');
|
|
449
|
-
}
|
|
450
|
-
else {
|
|
451
|
-
const staticFile = req.pathname.replace(DEV_SERVER_URL + '/', '');
|
|
452
|
-
req.filePath = path__default.join(devServerConfig.devServerDir, 'static', staticFile);
|
|
453
|
-
}
|
|
454
|
-
try {
|
|
455
|
-
req.stats = await fs.stat(req.filePath);
|
|
456
|
-
return serveFile(devServerConfig, fs, req, res);
|
|
457
|
-
}
|
|
458
|
-
catch (e) {
|
|
459
|
-
return serve404(devServerConfig, fs, req, res);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
catch (e) {
|
|
463
|
-
return serve500(devServerConfig, req, res, e);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
async function serveDevClientScript(devServerConfig, fs, req, res) {
|
|
467
|
-
const filePath = path__default.join(devServerConfig.devServerDir, 'static', 'dev-server-client.html');
|
|
468
|
-
let content = await fs.readFile(filePath);
|
|
469
|
-
const devClientConfig = {
|
|
470
|
-
basePath: devServerConfig.basePath,
|
|
471
|
-
editors: devServerConfig.editors,
|
|
472
|
-
reloadStrategy: devServerConfig.reloadStrategy
|
|
473
|
-
};
|
|
474
|
-
content = content.replace('window.__DEV_CLIENT_CONFIG__', JSON.stringify(devClientConfig));
|
|
475
|
-
res.writeHead(200, responseHeaders({
|
|
476
|
-
'Content-Type': 'text/html'
|
|
477
|
-
}));
|
|
478
|
-
res.write(content);
|
|
479
|
-
res.end();
|
|
480
|
-
if (devServerConfig.logRequests) {
|
|
481
|
-
sendMsg(process, {
|
|
482
|
-
requestLog: {
|
|
483
|
-
method: req.method,
|
|
484
|
-
url: req.url,
|
|
485
|
-
status: 200
|
|
486
|
-
}
|
|
487
|
-
});
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
async function serveDirectoryIndex(devServerConfig, fs, req, res) {
|
|
492
|
-
try {
|
|
493
|
-
const indexFilePath = path__default.join(req.filePath, 'index.html');
|
|
494
|
-
req.stats = await fs.stat(indexFilePath);
|
|
495
|
-
if (req.stats.isFile()) {
|
|
496
|
-
req.filePath = indexFilePath;
|
|
497
|
-
return serveFile(devServerConfig, fs, req, res);
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
catch (e) { }
|
|
501
|
-
if (!req.pathname.endsWith('/')) {
|
|
502
|
-
if (devServerConfig.logRequests) {
|
|
503
|
-
sendMsg(process, {
|
|
504
|
-
requestLog: {
|
|
505
|
-
method: req.method,
|
|
506
|
-
url: req.url,
|
|
507
|
-
status: 302
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
res.writeHead(302, {
|
|
512
|
-
'location': req.pathname + '/'
|
|
513
|
-
});
|
|
514
|
-
return res.end();
|
|
515
|
-
}
|
|
516
|
-
try {
|
|
517
|
-
const dirItemNames = await fs.readdir(req.filePath);
|
|
518
|
-
try {
|
|
519
|
-
const dirTemplatePath = path__default.join(devServerConfig.devServerDir, 'templates', 'directory-index.html');
|
|
520
|
-
const dirTemplate = await fs.readFile(dirTemplatePath);
|
|
521
|
-
const files = await getFiles(fs, req.filePath, req.pathname, dirItemNames);
|
|
522
|
-
const templateHtml = dirTemplate
|
|
523
|
-
.replace('{{title}}', getTitle(req.pathname))
|
|
524
|
-
.replace('{{nav}}', getName(req.pathname))
|
|
525
|
-
.replace('{{files}}', files);
|
|
526
|
-
res.writeHead(200, responseHeaders({
|
|
527
|
-
'Content-Type': 'text/html',
|
|
528
|
-
'X-Directory-Index': req.pathname
|
|
529
|
-
}));
|
|
530
|
-
res.write(templateHtml);
|
|
531
|
-
res.end();
|
|
532
|
-
if (devServerConfig.logRequests) {
|
|
533
|
-
sendMsg(process, {
|
|
534
|
-
requestLog: {
|
|
535
|
-
method: req.method,
|
|
536
|
-
url: req.url,
|
|
537
|
-
status: 200
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
catch (e) {
|
|
543
|
-
serve500(devServerConfig, req, res, e);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
catch (e) {
|
|
547
|
-
serve404(devServerConfig, fs, req, res);
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
async function getFiles(fs, filePath, urlPathName, dirItemNames) {
|
|
551
|
-
const items = await getDirectoryItems(fs, filePath, urlPathName, dirItemNames);
|
|
552
|
-
if (urlPathName !== '/') {
|
|
553
|
-
items.unshift({
|
|
554
|
-
isDirectory: true,
|
|
555
|
-
pathname: '../',
|
|
556
|
-
name: '..'
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
return items
|
|
560
|
-
.map(item => {
|
|
561
|
-
return (`
|
|
562
|
-
<li class="${item.isDirectory ? 'directory' : 'file'}">
|
|
563
|
-
<a href="${item.pathname}">
|
|
564
|
-
<span class="icon"></span>
|
|
565
|
-
<span>${item.name}</span>
|
|
566
|
-
</a>
|
|
567
|
-
</li>`);
|
|
568
|
-
})
|
|
569
|
-
.join('');
|
|
570
|
-
}
|
|
571
|
-
async function getDirectoryItems(fs, filePath, urlPathName, dirItemNames) {
|
|
572
|
-
const items = await Promise.all(dirItemNames.map(async (dirItemName) => {
|
|
573
|
-
const absPath = path__default.join(filePath, dirItemName);
|
|
574
|
-
const stats = await fs.stat(absPath);
|
|
575
|
-
const item = {
|
|
576
|
-
name: dirItemName,
|
|
577
|
-
pathname: Url.resolve(urlPathName, dirItemName),
|
|
578
|
-
isDirectory: stats.isDirectory()
|
|
579
|
-
};
|
|
580
|
-
return item;
|
|
581
|
-
}));
|
|
582
|
-
return items;
|
|
583
|
-
}
|
|
584
|
-
function getTitle(pathName) {
|
|
585
|
-
return pathName;
|
|
586
|
-
}
|
|
587
|
-
function getName(pathName) {
|
|
588
|
-
const dirs = pathName.split('/');
|
|
589
|
-
dirs.pop();
|
|
590
|
-
let url = '';
|
|
591
|
-
return dirs.map((dir, index) => {
|
|
592
|
-
url += dir + '/';
|
|
593
|
-
const text = (index === 0 ? `~` : dir);
|
|
594
|
-
return `<a href="${url}">${text}</a>`;
|
|
595
|
-
}).join('<span>/</span>') + '<span>/</span>';
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
function createRequestHandler(devServerConfig, fs) {
|
|
599
|
-
return async function (incomingReq, res) {
|
|
600
|
-
try {
|
|
601
|
-
const req = normalizeHttpRequest(devServerConfig, incomingReq);
|
|
602
|
-
if (req.url === '') {
|
|
603
|
-
res.writeHead(302, { 'location': '/' });
|
|
604
|
-
if (devServerConfig.logRequests) {
|
|
605
|
-
sendMsg(process, {
|
|
606
|
-
requestLog: {
|
|
607
|
-
method: req.method,
|
|
608
|
-
url: req.url,
|
|
609
|
-
status: 302
|
|
610
|
-
}
|
|
611
|
-
});
|
|
612
|
-
}
|
|
613
|
-
return res.end();
|
|
614
|
-
}
|
|
615
|
-
if (isDevClient(req.pathname) && devServerConfig.websocket) {
|
|
616
|
-
return serveDevClient(devServerConfig, fs, req, res);
|
|
617
|
-
}
|
|
618
|
-
if (!req.url.startsWith(devServerConfig.basePath)) {
|
|
619
|
-
if (devServerConfig.logRequests) {
|
|
620
|
-
sendMsg(process, {
|
|
621
|
-
requestLog: {
|
|
622
|
-
method: req.method,
|
|
623
|
-
url: req.url,
|
|
624
|
-
status: 404
|
|
625
|
-
}
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
return serve404Content(devServerConfig, req, res, `404 File Not Found, base path: ${devServerConfig.basePath}`);
|
|
629
|
-
}
|
|
630
|
-
try {
|
|
631
|
-
req.stats = await fs.stat(req.filePath);
|
|
632
|
-
if (req.stats.isFile()) {
|
|
633
|
-
return serveFile(devServerConfig, fs, req, res);
|
|
634
|
-
}
|
|
635
|
-
if (req.stats.isDirectory()) {
|
|
636
|
-
return serveDirectoryIndex(devServerConfig, fs, req, res);
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
catch (e) { }
|
|
640
|
-
if (isValidHistoryApi(devServerConfig, req)) {
|
|
641
|
-
try {
|
|
642
|
-
const indexFilePath = path__default.join(devServerConfig.root, devServerConfig.historyApiFallback.index);
|
|
643
|
-
req.stats = await fs.stat(indexFilePath);
|
|
644
|
-
if (req.stats.isFile()) {
|
|
645
|
-
req.filePath = indexFilePath;
|
|
646
|
-
return serveFile(devServerConfig, fs, req, res);
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
catch (e) { }
|
|
650
|
-
}
|
|
651
|
-
return serve404(devServerConfig, fs, req, res);
|
|
652
|
-
}
|
|
653
|
-
catch (e) {
|
|
654
|
-
return serve500(devServerConfig, incomingReq, res, e);
|
|
655
|
-
}
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
function normalizeHttpRequest(devServerConfig, incomingReq) {
|
|
659
|
-
const req = {
|
|
660
|
-
method: (incomingReq.method || 'GET').toUpperCase(),
|
|
661
|
-
headers: incomingReq.headers,
|
|
662
|
-
acceptHeader: (incomingReq.headers && typeof incomingReq.headers.accept === 'string' && incomingReq.headers.accept) || '',
|
|
663
|
-
url: (incomingReq.url || '').trim() || '',
|
|
664
|
-
host: (incomingReq.headers && typeof incomingReq.headers.host === 'string' && incomingReq.headers.host) || null
|
|
665
|
-
};
|
|
666
|
-
const parsedUrl = Url.parse(req.url);
|
|
667
|
-
const parts = (parsedUrl.pathname || '').replace(/\\/g, '/').split('/');
|
|
668
|
-
req.pathname = parts.map(part => decodeURIComponent(part)).join('/');
|
|
669
|
-
if (req.pathname.length > 0 && !isDevClient(req.pathname)) {
|
|
670
|
-
req.pathname = '/' + req.pathname.substring(devServerConfig.basePath.length);
|
|
671
|
-
}
|
|
672
|
-
req.filePath = utils.normalizePath(path__default.normalize(path__default.join(devServerConfig.root, path__default.relative('/', req.pathname))));
|
|
673
|
-
return req;
|
|
674
|
-
}
|
|
675
|
-
function isValidHistoryApi(devServerConfig, req) {
|
|
676
|
-
if (!devServerConfig.historyApiFallback) {
|
|
677
|
-
return false;
|
|
678
|
-
}
|
|
679
|
-
if (req.method !== 'GET') {
|
|
680
|
-
return false;
|
|
681
|
-
}
|
|
682
|
-
if (!req.acceptHeader.includes('text/html')) {
|
|
683
|
-
return false;
|
|
684
|
-
}
|
|
685
|
-
if (!devServerConfig.historyApiFallback.disableDotRule && req.pathname.includes('.')) {
|
|
686
|
-
return false;
|
|
687
|
-
}
|
|
688
|
-
return true;
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
async function findClosestOpenPort(host, port) {
|
|
692
|
-
async function t(portToCheck) {
|
|
693
|
-
const isTaken = await isPortTaken(host, portToCheck);
|
|
694
|
-
if (!isTaken) {
|
|
695
|
-
return portToCheck;
|
|
696
|
-
}
|
|
697
|
-
return t(portToCheck + 1);
|
|
698
|
-
}
|
|
699
|
-
return t(port);
|
|
700
|
-
}
|
|
701
|
-
function isPortTaken(host, port) {
|
|
702
|
-
return new Promise((resolve, reject) => {
|
|
703
|
-
const tester = net.createServer()
|
|
704
|
-
.once('error', () => {
|
|
705
|
-
resolve(true);
|
|
706
|
-
})
|
|
707
|
-
.once('listening', () => {
|
|
708
|
-
tester.once('close', () => {
|
|
709
|
-
resolve(false);
|
|
710
|
-
})
|
|
711
|
-
.close();
|
|
712
|
-
})
|
|
713
|
-
.on('error', (err) => {
|
|
714
|
-
reject(err);
|
|
715
|
-
})
|
|
716
|
-
.listen(port, host);
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
async function createHttpServer(devServerConfig, fs, destroys) {
|
|
721
|
-
// figure out the port to be listening on
|
|
722
|
-
// by figuring out the first one available
|
|
723
|
-
devServerConfig.port = await findClosestOpenPort(devServerConfig.address, devServerConfig.port);
|
|
724
|
-
// create our request handler
|
|
725
|
-
const reqHandler = createRequestHandler(devServerConfig, fs);
|
|
726
|
-
const credentials = devServerConfig.https;
|
|
727
|
-
let server = credentials ? https.createServer(credentials, reqHandler) : http.createServer(reqHandler);
|
|
728
|
-
destroys.push(() => {
|
|
729
|
-
// close down the serve on destroy
|
|
730
|
-
server.close();
|
|
731
|
-
server = null;
|
|
732
|
-
});
|
|
733
|
-
return server;
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
const WebSocket = require('../sys/node/websocket').WebSocket;
|
|
737
|
-
function createWebSocket(process, httpServer, destroys) {
|
|
738
|
-
const wsConfig = {
|
|
739
|
-
server: httpServer
|
|
740
|
-
};
|
|
741
|
-
const wsServer = new WebSocket.Server(wsConfig);
|
|
742
|
-
function heartbeat() {
|
|
743
|
-
this.isAlive = true;
|
|
744
|
-
}
|
|
745
|
-
wsServer.on('connection', (ws) => {
|
|
746
|
-
ws.on('message', (data) => {
|
|
747
|
-
// the server process has received a message from the browser
|
|
748
|
-
// pass the message received from the browser to the main cli process
|
|
749
|
-
process.send(JSON.parse(data.toString()));
|
|
750
|
-
});
|
|
751
|
-
ws.isAlive = true;
|
|
752
|
-
ws.on('pong', heartbeat);
|
|
753
|
-
});
|
|
754
|
-
const pingInternval = setInterval(() => {
|
|
755
|
-
wsServer.clients.forEach((ws) => {
|
|
756
|
-
if (!ws.isAlive) {
|
|
757
|
-
return ws.close(1000);
|
|
758
|
-
}
|
|
759
|
-
ws.isAlive = false;
|
|
760
|
-
ws.ping(utils.noop);
|
|
761
|
-
});
|
|
762
|
-
}, 10000);
|
|
763
|
-
function onMessageFromCli(msg) {
|
|
764
|
-
// the server process has received a message from the cli's main thread
|
|
765
|
-
// pass the data to each web socket for each browser/tab connected
|
|
766
|
-
if (msg) {
|
|
767
|
-
const data = JSON.stringify(msg);
|
|
768
|
-
wsServer.clients.forEach(ws => {
|
|
769
|
-
if (ws.readyState === ws.OPEN) {
|
|
770
|
-
ws.send(data);
|
|
771
|
-
}
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
process.addListener('message', onMessageFromCli);
|
|
776
|
-
destroys.push(() => {
|
|
777
|
-
clearInterval(pingInternval);
|
|
778
|
-
wsServer.clients.forEach(ws => {
|
|
779
|
-
ws.close(1000);
|
|
780
|
-
});
|
|
781
|
-
});
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
/*
|
|
785
|
-
* exit
|
|
786
|
-
* https://github.com/cowboy/node-exit
|
|
787
|
-
*
|
|
788
|
-
* Copyright (c) 2013 "Cowboy" Ben Alman
|
|
789
|
-
* Licensed under the MIT license.
|
|
790
|
-
*/
|
|
791
|
-
|
|
792
|
-
var exit = function exit(exitCode, streams) {
|
|
793
|
-
if (!streams) { streams = [process.stdout, process.stderr]; }
|
|
794
|
-
var drainCount = 0;
|
|
795
|
-
// Actually exit if all streams are drained.
|
|
796
|
-
function tryToExit() {
|
|
797
|
-
if (drainCount === streams.length) {
|
|
798
|
-
process.exit(exitCode);
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
streams.forEach(function(stream) {
|
|
802
|
-
// Count drained streams now, but monitor non-drained streams.
|
|
803
|
-
if (stream.bufferSize === 0) {
|
|
804
|
-
drainCount++;
|
|
805
|
-
} else {
|
|
806
|
-
stream.write('', 'utf-8', function() {
|
|
807
|
-
drainCount++;
|
|
808
|
-
tryToExit();
|
|
809
|
-
});
|
|
810
|
-
}
|
|
811
|
-
// Prevent further writing.
|
|
812
|
-
stream.write = function() {};
|
|
813
|
-
});
|
|
814
|
-
// If all streams were already drained, exit now.
|
|
815
|
-
tryToExit();
|
|
816
|
-
// In Windows, when run as a Node.js child process, a script utilizing
|
|
817
|
-
// this library might just exit with a 0 exit code, regardless. This code,
|
|
818
|
-
// despite the fact that it looks a bit crazy, appears to fix that.
|
|
819
|
-
process.on('exit', function() {
|
|
820
|
-
process.exit(exitCode);
|
|
821
|
-
});
|
|
822
|
-
};
|
|
823
|
-
|
|
824
|
-
async function startDevServerWorker(process, devServerConfig, fs) {
|
|
825
|
-
try {
|
|
826
|
-
const destroys = [];
|
|
827
|
-
devServerConfig.editors = await getEditors();
|
|
828
|
-
// create the http server listening for and responding to requests from the browser
|
|
829
|
-
let httpServer = await createHttpServer(devServerConfig, fs, destroys);
|
|
830
|
-
if (devServerConfig.websocket) {
|
|
831
|
-
// upgrade web socket requests the server receives
|
|
832
|
-
createWebSocket(process, httpServer, destroys);
|
|
833
|
-
}
|
|
834
|
-
// start listening!
|
|
835
|
-
httpServer.listen(devServerConfig.port, devServerConfig.address);
|
|
836
|
-
// have the server worker send a message to the main cli
|
|
837
|
-
// process that the server has successfully started up
|
|
838
|
-
sendMsg(process, {
|
|
839
|
-
serverStated: {
|
|
840
|
-
browserUrl: getBrowserUrl(devServerConfig.protocol, devServerConfig.address, devServerConfig.port, devServerConfig.basePath, '/'),
|
|
841
|
-
initialLoadUrl: getBrowserUrl(devServerConfig.protocol, devServerConfig.address, devServerConfig.port, devServerConfig.basePath, devServerConfig.initialLoadUrl || DEV_SERVER_INIT_URL)
|
|
842
|
-
}
|
|
843
|
-
});
|
|
844
|
-
const closeServer = () => {
|
|
845
|
-
// probably recived a SIGINT message from the parent cli process
|
|
846
|
-
// let's do our best to gracefully close everything down first
|
|
847
|
-
destroys.forEach(destroy => {
|
|
848
|
-
destroy();
|
|
849
|
-
});
|
|
850
|
-
destroys.length = 0;
|
|
851
|
-
httpServer = null;
|
|
852
|
-
setTimeout(() => {
|
|
853
|
-
exit(0);
|
|
854
|
-
}, 5000).unref();
|
|
855
|
-
process.removeAllListeners('message');
|
|
856
|
-
};
|
|
857
|
-
process.once('SIGINT', closeServer);
|
|
858
|
-
}
|
|
859
|
-
catch (e) {
|
|
860
|
-
sendError(process, e);
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
async function startServer(devServerConfig) {
|
|
865
|
-
// received a message from main to start the server
|
|
866
|
-
try {
|
|
867
|
-
const fs = new node.NodeFs(process);
|
|
868
|
-
devServerConfig.contentTypes = await loadContentTypes(fs);
|
|
869
|
-
startDevServerWorker(process, devServerConfig, fs);
|
|
870
|
-
}
|
|
871
|
-
catch (e) {
|
|
872
|
-
sendError(process, e);
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
async function loadContentTypes(fs) {
|
|
876
|
-
const contentTypePath = path__default.join(__dirname, 'content-type-db.json');
|
|
877
|
-
const contentTypeJson = await fs.readFile(contentTypePath);
|
|
878
|
-
return JSON.parse(contentTypeJson);
|
|
879
|
-
}
|
|
880
|
-
process.on('message', (msg) => {
|
|
881
|
-
if (msg.startServer) {
|
|
882
|
-
startServer(msg.startServer);
|
|
883
|
-
}
|
|
884
|
-
});
|
|
885
|
-
process.on('unhandledRejection', (e) => {
|
|
886
|
-
console.log(e);
|
|
887
|
-
});
|