clojurific 0.12.1 → 0.12.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.
Files changed (123) hide show
  1. package/README.md +3 -2
  2. package/cljf/launcher.js +15 -8
  3. package/package.json +2 -2
  4. package/compiler/deps.edn +0 -9
  5. package/compiler/src/main/cljs/cljs/analyzer/passes/and_or.cljc +0 -118
  6. package/compiler/src/main/cljs/cljs/analyzer/passes/lite.cljc +0 -32
  7. package/compiler/src/main/cljs/cljs/analyzer/passes.cljc +0 -32
  8. package/compiler/src/main/cljs/cljs/bootstrap_nodejs.js +0 -154
  9. package/compiler/src/main/cljs/cljs/core/specs/alpha.cljc +0 -272
  10. package/compiler/src/main/cljs/cljs/core/specs/alpha.cljs +0 -10
  11. package/compiler/src/main/cljs/cljs/core.cljs +0 -13194
  12. package/compiler/src/main/cljs/cljs/esm/goog/array.js +0 -61
  13. package/compiler/src/main/cljs/cljs/esm/goog/math.js +0 -1846
  14. package/compiler/src/main/cljs/cljs/esm/goog/object.js +0 -80
  15. package/compiler/src/main/cljs/cljs/esm/goog/string.js +0 -192
  16. package/compiler/src/main/cljs/cljs/esm/goog/userAgent/product.js +0 -10
  17. package/compiler/src/main/cljs/cljs/esm/goog.js +0 -90
  18. package/compiler/src/main/cljs/cljs/esm/karma.cljs +0 -103
  19. package/compiler/src/main/cljs/cljs/esm/lazy.clj +0 -51
  20. package/compiler/src/main/cljs/cljs/esm/lazy.cljs +0 -49
  21. package/compiler/src/main/cljs/cljs/esm/node_test.cljs +0 -21
  22. package/compiler/src/main/cljs/cljs/esm/repl_runtime.cljs +0 -353
  23. package/compiler/src/main/cljs/cljs/externs.js +0 -27
  24. package/compiler/src/main/cljs/cljs/imul.js +0 -11
  25. package/compiler/src/main/cljs/cljs/js.clj +0 -24
  26. package/compiler/src/main/cljs/cljs/js.cljs +0 -1432
  27. package/compiler/src/main/cljs/cljs/loader.cljs +0 -107
  28. package/compiler/src/main/cljs/cljs/main.clj +0 -67
  29. package/compiler/src/main/cljs/cljs/math.cljs +0 -869
  30. package/compiler/src/main/cljs/cljs/module_deps.js +0 -250
  31. package/compiler/src/main/cljs/cljs/nodejs.cljs +0 -27
  32. package/compiler/src/main/cljs/cljs/nodejs_externs.js +0 -3
  33. package/compiler/src/main/cljs/cljs/nodejscli.cljs +0 -22
  34. package/compiler/src/main/cljs/cljs/pprint.cljc +0 -167
  35. package/compiler/src/main/cljs/cljs/pprint.cljs +0 -3325
  36. package/compiler/src/main/cljs/cljs/proxy/impl.cljs +0 -32
  37. package/compiler/src/main/cljs/cljs/proxy.cljs +0 -184
  38. package/compiler/src/main/cljs/cljs/reader.clj +0 -18
  39. package/compiler/src/main/cljs/cljs/reader.cljs +0 -214
  40. package/compiler/src/main/cljs/cljs/repl.cljs +0 -206
  41. package/compiler/src/main/cljs/cljs/source_map/base64.cljs +0 -25
  42. package/compiler/src/main/cljs/cljs/source_map/base64_vlq.cljs +0 -102
  43. package/compiler/src/main/cljs/cljs/source_map.cljs +0 -305
  44. package/compiler/src/main/cljs/cljs/spec/alpha.cljc +0 -564
  45. package/compiler/src/main/cljs/cljs/spec/alpha.cljs +0 -1510
  46. package/compiler/src/main/cljs/cljs/spec/gen/alpha.cljc +0 -68
  47. package/compiler/src/main/cljs/cljs/spec/gen/alpha.cljs +0 -183
  48. package/compiler/src/main/cljs/cljs/spec/test/alpha.cljc +0 -329
  49. package/compiler/src/main/cljs/cljs/spec/test/alpha.cljs +0 -380
  50. package/compiler/src/main/cljs/cljs/stacktrace.cljc +0 -578
  51. package/compiler/src/main/cljs/cljs/test.cljc +0 -458
  52. package/compiler/src/main/cljs/cljs/test.cljs +0 -606
  53. package/compiler/src/main/cljs/clojure/browser/dom.cljs +0 -152
  54. package/compiler/src/main/cljs/clojure/browser/event.cljs +0 -101
  55. package/compiler/src/main/cljs/clojure/browser/net.cljs +0 -181
  56. package/compiler/src/main/cljs/clojure/browser/repl/preload.cljs +0 -13
  57. package/compiler/src/main/cljs/clojure/browser/repl.cljs +0 -283
  58. package/compiler/src/main/cljs/clojure/core/protocols.cljs +0 -29
  59. package/compiler/src/main/cljs/clojure/core/reducers.cljs +0 -312
  60. package/compiler/src/main/cljs/clojure/data.cljs +0 -162
  61. package/compiler/src/main/cljs/clojure/datafy.cljs +0 -63
  62. package/compiler/src/main/cljs/clojure/edn.cljs +0 -55
  63. package/compiler/src/main/cljs/clojure/reflect.cljs +0 -57
  64. package/compiler/src/main/cljs/clojure/set.cljs +0 -165
  65. package/compiler/src/main/cljs/clojure/string.cljs +0 -290
  66. package/compiler/src/main/cljs/clojure/walk.cljs +0 -98
  67. package/compiler/src/main/cljs/clojure/zip.cljs +0 -291
  68. package/compiler/src/main/cljs/process/env.cljs +0 -12
  69. package/compiler/src/main/cljs/shadow/resource.clj +0 -60
  70. package/compiler/src/main/cljs/shadow/resource.cljs +0 -10
  71. package/compiler/src/main/clojure/cljs/analyzer/api.cljc +0 -299
  72. package/compiler/src/main/clojure/cljs/analyzer/impl/namespaces.cljc +0 -68
  73. package/compiler/src/main/clojure/cljs/analyzer/impl.cljc +0 -59
  74. package/compiler/src/main/clojure/cljs/analyzer/macros.clj +0 -57
  75. package/compiler/src/main/clojure/cljs/analyzer/utils.clj +0 -36
  76. package/compiler/src/main/clojure/cljs/analyzer.cljc +0 -5292
  77. package/compiler/src/main/clojure/cljs/build/api.clj +0 -309
  78. package/compiler/src/main/clojure/cljs/cli.clj +0 -812
  79. package/compiler/src/main/clojure/cljs/closure.clj +0 -3440
  80. package/compiler/src/main/clojure/cljs/compiler/api.clj +0 -101
  81. package/compiler/src/main/clojure/cljs/compiler/macros.clj +0 -16
  82. package/compiler/src/main/clojure/cljs/compiler.cljc +0 -2748
  83. package/compiler/src/main/clojure/cljs/core/macros.clj +0 -43
  84. package/compiler/src/main/clojure/cljs/core/server.clj +0 -167
  85. package/compiler/src/main/clojure/cljs/core.cljc +0 -3719
  86. package/compiler/src/main/clojure/cljs/env/macros.clj +0 -37
  87. package/compiler/src/main/clojure/cljs/env.cljc +0 -102
  88. package/compiler/src/main/clojure/cljs/esm/repl/nrepl.clj +0 -151
  89. package/compiler/src/main/clojure/cljs/esm/repl.clj +0 -878
  90. package/compiler/src/main/clojure/cljs/esm.clj +0 -987
  91. package/compiler/src/main/clojure/cljs/externs/default.edn +0 -1549
  92. package/compiler/src/main/clojure/cljs/externs.clj +0 -479
  93. package/compiler/src/main/clojure/cljs/foreign/node.clj +0 -207
  94. package/compiler/src/main/clojure/cljs/instant.clj +0 -54
  95. package/compiler/src/main/clojure/cljs/js_deps.cljc +0 -412
  96. package/compiler/src/main/clojure/cljs/module_graph.cljc +0 -402
  97. package/compiler/src/main/clojure/cljs/repl/bootstrap.clj +0 -53
  98. package/compiler/src/main/clojure/cljs/repl/browser.clj +0 -540
  99. package/compiler/src/main/clojure/cljs/repl/node.clj +0 -253
  100. package/compiler/src/main/clojure/cljs/repl/node_repl.js +0 -114
  101. package/compiler/src/main/clojure/cljs/repl/reflect.clj +0 -85
  102. package/compiler/src/main/clojure/cljs/repl/server.clj +0 -236
  103. package/compiler/src/main/clojure/cljs/repl.cljc +0 -1615
  104. package/compiler/src/main/clojure/cljs/server/browser.clj +0 -54
  105. package/compiler/src/main/clojure/cljs/server/node.clj +0 -54
  106. package/compiler/src/main/clojure/cljs/source_map/base64.clj +0 -28
  107. package/compiler/src/main/clojure/cljs/source_map/base64_vlq.clj +0 -104
  108. package/compiler/src/main/clojure/cljs/source_map.clj +0 -369
  109. package/compiler/src/main/clojure/cljs/support.cljc +0 -18
  110. package/compiler/src/main/clojure/cljs/tagged_literals.cljc +0 -93
  111. package/compiler/src/main/clojure/cljs/util.cljc +0 -420
  112. package/compiler/src/main/clojure/cljs/vendor/bridge.clj +0 -42
  113. package/compiler/src/main/clojure/cljs/vendor/clojure/data/json.clj +0 -809
  114. package/compiler/src/main/clojure/cljs/vendor/clojure/tools/reader/default_data_readers.clj +0 -303
  115. package/compiler/src/main/clojure/cljs/vendor/clojure/tools/reader/edn.clj +0 -440
  116. package/compiler/src/main/clojure/cljs/vendor/clojure/tools/reader/impl/commons.clj +0 -131
  117. package/compiler/src/main/clojure/cljs/vendor/clojure/tools/reader/impl/errors.clj +0 -214
  118. package/compiler/src/main/clojure/cljs/vendor/clojure/tools/reader/impl/inspect.clj +0 -91
  119. package/compiler/src/main/clojure/cljs/vendor/clojure/tools/reader/impl/utils.clj +0 -127
  120. package/compiler/src/main/clojure/cljs/vendor/clojure/tools/reader/reader_types.clj +0 -431
  121. package/compiler/src/main/clojure/cljs/vendor/clojure/tools/reader.clj +0 -1035
  122. package/compiler/src/main/clojure/cljs/vendor/cognitect/transit.clj +0 -479
  123. /package/{compiler/no-clojurescript → no-clojurescript}/deps.edn +0 -0
package/README.md CHANGED
@@ -5,8 +5,9 @@ ClojureScript compiled to ES modules, bundled by Vite.
5
5
  [Clojurific](https://github.com/WhimsicalCode/clojurific) is a fork of
6
6
  ClojureScript whose `:module-format :esm` compiles every namespace to an ES
7
7
  module, leaving bundling, minification, npm packages and TypeScript to Vite,
8
- without the Google Closure Compiler. This package has the compiler, the `cljf`
9
- command, a Vite plugin with hot reloading, and a Karma adapter. It needs
8
+ without the Google Closure Compiler. This package has the `cljf` command, a
9
+ Vite plugin with hot reloading, and a Karma adapter; `cljf` gets the compiler,
10
+ `com.whimsical/clojurific`, from Clojars. It needs
10
11
  Node.js 20 or later and Java 17 or later, not the Clojure CLI.
11
12
 
12
13
  Status: experimental. Versions are `0.<minor>.<release>`: `<minor>` is the
package/cljf/launcher.js CHANGED
@@ -21,11 +21,18 @@ const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '
21
21
 
22
22
  export const version = JSON.parse(readFileSync(path.join(packageRoot, 'package.json'), 'utf8')).version;
23
23
 
24
- // The compiler's sources: compiler/ in the npm package, the fork itself
25
- // (src/main/js is the package's root) when run from its repository
26
- export const compilerDir = existsSync(path.join(packageRoot, 'compiler', 'deps.edn'))
27
- ? path.join(packageRoot, 'compiler')
28
- : path.resolve(packageRoot, '../../..');
24
+ // Whether this is the npm package, which has no-clojurescript/, rather than
25
+ // the fork's repository (src/main/js is the package's root)
26
+ const packaged = existsSync(path.join(packageRoot, 'no-clojurescript', 'deps.edn'));
27
+
28
+ // The fork's repository, its compiler's sources, when run from it
29
+ export const compilerDir = packaged ? null : path.resolve(packageRoot, '../../..');
30
+
31
+ // The compiler: the npm package's version from Clojars (com.whimsical/clojurific
32
+ // is released with the package), or the fork's sources
33
+ export const compiler = packaged ? { ':mvn/version': version } : { ':local/root': compilerDir };
34
+
35
+ const noClojureScript = path.join(packaged ? packageRoot : compilerDir, 'no-clojurescript');
29
36
 
30
37
  const log = line => process.stderr.write(`${line}\n`);
31
38
 
@@ -37,7 +44,7 @@ export function normalizeAliases(aliases = []) {
37
44
 
38
45
  function cacheKey(aliases) {
39
46
  return createHash('sha256')
40
- .update(JSON.stringify({ version, compiler: compilerDir, aliases }))
47
+ .update(JSON.stringify({ version, compiler, aliases }))
41
48
  .digest('hex')
42
49
  .slice(0, 32);
43
50
  }
@@ -75,8 +82,8 @@ async function resolve({ project, aliases, java, cache, env, log }) {
75
82
  const output = `${cache}.resolve.json`;
76
83
  await fs.writeFile(input, edn({
77
84
  ':aliases': aliases,
78
- ':compiler': { ':local/root': compilerDir },
79
- ':no-clojurescript': { ':local/root': path.join(compilerDir, 'no-clojurescript') },
85
+ ':compiler': compiler,
86
+ ':no-clojurescript': { ':local/root': noClojureScript },
80
87
  ':output': output,
81
88
  }));
82
89
  log('cljf: resolving dependencies');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clojurific",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "description": "ClojureScript compiled to ES modules, bundled by Vite",
5
5
  "license": "EPL-1.0",
6
6
  "repository": {
@@ -24,7 +24,7 @@
24
24
  "cljf/resolver/clojurific",
25
25
  "vite-plugin-cljs",
26
26
  "karma-esm",
27
- "compiler"
27
+ "no-clojurescript"
28
28
  ],
29
29
  "engines": {
30
30
  "node": ">=20"
package/compiler/deps.edn DELETED
@@ -1,9 +0,0 @@
1
- {:paths ["src/main/clojure" "src/main/cljs"],
2
- :deps
3
- {com.cognitect/transit-java {:mvn/version "1.0.362"},
4
- org.clojure/clojure {:mvn/version "1.12.6"},
5
- org.clojure/core.specs.alpha {:mvn/version "0.1.24"},
6
- org.clojure/google-closure-library
7
- {:mvn/version "0.0-20250515-f04e4c0e"},
8
- org.clojure/spec.alpha {:mvn/version "0.1.143"},
9
- org.clojure/tools.reader {:mvn/version "1.3.6"}}}
@@ -1,118 +0,0 @@
1
- ;; Copyright (c) Rich Hickey. All rights reserved.
2
- ;; The use and distribution terms for this software are covered by the
3
- ;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
4
- ;; which can be found in the file epl-v10.html at the root of this distribution.
5
- ;; By using this software in any fashion, you are agreeing to be bound by
6
- ;; the terms of this license.
7
- ;; You must not remove this notice, or any other, from this software.
8
-
9
- (ns cljs.analyzer.passes.and-or
10
- (:require [cljs.analyzer.passes :as passes]))
11
-
12
- (def simple-ops
13
- #{:var :js-var :local :invoke :const :host-field :host-call :js :quote})
14
-
15
- (defn ->expr-env [ast]
16
- (assoc-in ast [:env :context] :expr))
17
-
18
- (defn simple-op? [ast]
19
- (contains? simple-ops (:op ast)))
20
-
21
- (defn simple-test-expr?
22
- [{:keys [op] :as ast}]
23
- (boolean
24
- (and (simple-op? ast)
25
- ('#{boolean seq}
26
- (or (:tag ast)
27
- (when (#{:local :var} op)
28
- (-> ast :info :tag)))))))
29
-
30
- (defn single-binding-let? [ast]
31
- (and (= :let (:op ast))
32
- (= 1 (count (-> ast :bindings)))))
33
-
34
- (defn no-statements? [let-ast]
35
- (= [] (-> let-ast :body :statements)))
36
-
37
- (defn returns-if? [let-ast]
38
- (= :if (-> let-ast :body :ret :op)))
39
-
40
- (defn simple-test-binding-let? [ast]
41
- (and (single-binding-let? ast)
42
- (no-statements? ast)
43
- (simple-test-expr? (-> ast :bindings first :init))
44
- (returns-if? ast)))
45
-
46
- (defn test=then? [if-ast]
47
- ;; remove :env, if same, local will differ only by
48
- ;; :context (:expr | :statement)
49
- (= (dissoc (:test if-ast) :env)
50
- (dissoc (:then if-ast) :env)))
51
-
52
- (defn test=else? [if-ast]
53
- ;; remove :env, if same, local will differ only by
54
- ;; :context (:expr | :statement)
55
- (= (dissoc (:test if-ast) :env)
56
- (dissoc (:else if-ast) :env)))
57
-
58
- (defn simple-and? [ast]
59
- (and (simple-test-binding-let? ast)
60
- (test=else? (-> ast :body :ret))))
61
-
62
- (defn simple-or? [ast]
63
- (and (simple-test-binding-let? ast)
64
- (test=then? (-> ast :body :ret))))
65
-
66
- (defn optimizable-and? [ast]
67
- (and (simple-and? ast)
68
- (simple-test-expr? (-> ast :body :ret :then))))
69
-
70
- (defn optimizable-or? [ast]
71
- (and (simple-or? ast)
72
- (simple-test-expr? (-> ast :body :ret :else))))
73
-
74
- (defn remove-loop-let [fn-ast local]
75
- (update fn-ast :loop-lets
76
- (fn [loop-lets]
77
- (map
78
- (fn [m]
79
- (update m :params
80
- (fn [xs] (remove #(= local (:name %)) xs))))
81
- loop-lets))))
82
-
83
- (defn remove-local-pass [local]
84
- (fn [env ast opts]
85
- (cond-> (update-in ast [:env :locals] dissoc local)
86
- (= :fn (:op ast)) (remove-loop-let local))))
87
-
88
- (defn optimize-and [ast]
89
- (let [{:keys [init name]} (-> ast :bindings first)]
90
- {:op :js
91
- :env (:env ast)
92
- :segs ["((" ") && (" "))"]
93
- :args [init
94
- (passes/walk
95
- (->expr-env (-> ast :body :ret :then))
96
- [(remove-local-pass name)])]
97
- :form (:form ast)
98
- :children [:args]
99
- :tag 'boolean}))
100
-
101
- (defn optimize-or [ast]
102
- (let [{:keys [init name]} (-> ast :bindings first)]
103
- {:op :js
104
- :env (:env ast)
105
- :segs ["((" ") || (" "))"]
106
- :args [init
107
- (passes/walk
108
- (->expr-env (-> ast :body :ret :else))
109
- [(remove-local-pass name)])]
110
- :form (:form ast)
111
- :children [:args]
112
- :tag 'boolean}))
113
-
114
- (defn optimize [env ast _]
115
- (cond
116
- (optimizable-and? ast) (optimize-and ast)
117
- (optimizable-or? ast) (optimize-or ast)
118
- :else ast))
@@ -1,32 +0,0 @@
1
- ;; Copyright (c) Rich Hickey. All rights reserved.
2
- ;; The use and distribution terms for this software are covered by the
3
- ;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
4
- ;; which can be found in the file epl-v10.html at the root of this distribution.
5
- ;; By using this software in any fashion, you are agreeing to be bound by
6
- ;; the terms of this license.
7
- ;; You must not remove this notice, or any other, from this software.
8
-
9
- (ns cljs.analyzer.passes.lite
10
- (:refer-clojure :exclude [var?]))
11
-
12
- (defn var? [ast]
13
- (= :var (:op ast)))
14
-
15
- (def ctor->ctor-lite
16
- '{cljs.core/vector cljs.core/vector-lite
17
- cljs.core/vec cljs.core/vec-lite})
18
-
19
- (defn update-var [{:keys [name] :as ast}]
20
- (let [replacement (get ctor->ctor-lite name)]
21
- (-> ast
22
- (assoc :name replacement)
23
- (assoc-in [:info :name] replacement))))
24
-
25
- (defn replace-var? [ast]
26
- (and (var? ast)
27
- (contains? ctor->ctor-lite (:name ast))))
28
-
29
- (defn use-lite-types
30
- [env ast _]
31
- (cond-> ast
32
- (replace-var? ast) update-var))
@@ -1,32 +0,0 @@
1
- ;; Copyright (c) Rich Hickey. All rights reserved.
2
- ;; The use and distribution terms for this software are covered by the
3
- ;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
4
- ;; which can be found in the file epl-v10.html at the root of this distribution.
5
- ;; By using this software in any fashion, you are agreeing to be bound by
6
- ;; the terms of this license.
7
- ;; You must not remove this notice, or any other, from this software.
8
-
9
- (ns cljs.analyzer.passes)
10
-
11
- (defn apply-passes
12
- ([ast passes]
13
- (apply-passes ast passes nil))
14
- ([ast passes opts]
15
- (reduce
16
- (fn [ast pass]
17
- (pass (:env ast) ast opts))
18
- ast passes)))
19
-
20
- (defn walk
21
- ([ast passes]
22
- (walk ast passes nil))
23
- ([ast passes opts]
24
- (reduce
25
- (fn [ast child-k]
26
- (assoc ast
27
- child-k
28
- (let [child (get ast child-k)]
29
- (if (vector? child)
30
- (into [] (map #(walk % passes opts)) child)
31
- (walk child passes opts)))))
32
- (some-> ast (apply-passes passes opts)) (:children ast))))
@@ -1,154 +0,0 @@
1
- // Copyright 2013 The Closure Library Authors.
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS-IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- /**
16
- * @fileoverview A nodejs script for dynamically requiring Closure within
17
- * nodejs.
18
- *
19
- * Example of usage:
20
- * <code>
21
- * require('./bootstrap/nodejs')
22
- * goog.require('goog.ui.Component')
23
- * </code>
24
- *
25
- * This loads goog.ui.Component in the global scope.
26
- *
27
- * If you want to load custom libraries, you can require the custom deps file
28
- * directly. If your custom libraries introduce new globals, you may
29
- * need to run goog.nodeGlobalRequire to get them to load correctly.
30
- *
31
- * <code>
32
- * require('./path/to/my/deps.js')
33
- * goog.bootstrap.nodeJs.nodeGlobalRequire('./path/to/my/base.js')
34
- * goog.require('my.Class')
35
- * </code>
36
- *
37
- * @author nick@medium.com (Nick Santos)
38
- *
39
- * @nocompile
40
- */
41
-
42
- var fs = require("fs");
43
- var vm = require("vm");
44
- var path = require("path");
45
- var CLJS_ROOT = ".";
46
-
47
-
48
- /**
49
- * The goog namespace in the global scope.
50
- */
51
- global.goog = {};
52
-
53
-
54
- /**
55
- * Imports a script using Node's require() API.
56
- *
57
- * @param {string} src The script source.
58
- * @return {boolean} True if the script was imported, false otherwise.
59
- */
60
- global.CLOSURE_IMPORT_SCRIPT = function(src, opt_sourceText) {
61
- // if CLJS_ROOT has been rewritten (by REPLs) need to compute require path
62
- // so we can delete the old entry from the Node.js require cache
63
- if(CLJS_ROOT !== ".") {
64
- var cached = null;
65
- if(src.substring(0, 2) == "..") {
66
- cached = path.join(CLJS_ROOT, src.substring(3));
67
- } else {
68
- cached = path.join(CLJS_ROOT, "goog", src);
69
- }
70
- if(require.cache[cached]) delete require.cache[cached];
71
- }
72
-
73
- // Sources are always expressed relative to closure's base.js, but
74
- // require() is always relative to the current source.
75
- if (opt_sourceText === undefined) {
76
- var flags = null;
77
- if (goog.debugLoader_) {
78
- var dep = goog.debugLoader_.dependencies_[src];
79
- if (dep) {
80
- flags = dep.loadFlags;
81
- }
82
- } else {
83
- flags = goog.dependencies_.loadFlags[src];
84
- }
85
- if (flags && flags["foreign-lib"]) {
86
- nodeGlobalRequire(path.resolve(__dirname, "..", src));
87
- } else {
88
- require(path.join(".", "..", src));
89
- }
90
- } else {
91
- eval(opt_sourceText);
92
- }
93
- return true;
94
- };
95
-
96
-
97
- /**
98
- * Loads a file when using Closure's goog.require() API with goog.modules.
99
- *
100
- * @param {string} src The file source.
101
- * @return {string} The file contents.
102
- */
103
- global.CLOSURE_LOAD_FILE_SYNC = function(src) {
104
- return fs.readFileSync(
105
- path.resolve(__dirname, "..", src), {encoding: "utf-8"});
106
- };
107
-
108
-
109
- // Declared here so it can be used to require base.js
110
- function nodeGlobalRequire(file) {
111
- var _module = global.module,
112
- _exports = global.exports,
113
- exportedRequire = false;
114
-
115
- // to circumvent Node.js environment detection in bundled libraries
116
- global.module = undefined;
117
- global.exports = undefined;
118
-
119
- // to allow requires of Node.js libraries (i.e. platform libs) that
120
- // couldn't be bundled for some reason
121
- if(global.require == undefined) {
122
- exportedRequire = true;
123
- global.require = require;
124
- }
125
-
126
- vm.runInThisContext.call(global, fs.readFileSync(file), file);
127
-
128
- global.exports = _exports;
129
- global.module = _module;
130
-
131
- if(exportedRequire) {
132
- global.require = undefined;
133
- }
134
- }
135
-
136
-
137
- // Load Closure's base.js into memory. It is assumed base.js is in the
138
- // directory above this directory given this script's location in
139
- // bootstrap/nodejs.js.
140
- nodeGlobalRequire(path.resolve(__dirname, "..", "base.js"));
141
-
142
-
143
- /**
144
- * Bootstraps a file into the global scope.
145
- *
146
- * This is strictly for cases where normal require() won't work,
147
- * because the file declares global symbols with 'var' that need to
148
- * be added to the global scope.
149
- * @suppress {missingProvide}
150
- *
151
- * @param {string} file The path to the file.
152
- */
153
- goog.nodeGlobalRequire = nodeGlobalRequire;
154
-
@@ -1,272 +0,0 @@
1
- ; Copyright (c) Rich Hickey. All rights reserved.
2
- ; The use and distribution terms for this software are covered by the
3
- ; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
4
- ; which can be found in the file epl-v10.html at the root of this distribution.
5
- ; By using this software in any fashion, you are agreeing to be bound by
6
- ; the terms of this license.
7
- ; You must not remove this notice, or any other, from this software.
8
-
9
- (ns cljs.core.specs.alpha
10
- (:require [clojure.spec.alpha :as s]
11
- #?(:clj [cljs.core :as core]
12
- :cljs [cljs.core$macros :as core])))
13
-
14
- ;;;; destructure
15
-
16
- (s/def ::local-name (s/and simple-symbol? #(not= '& %)))
17
-
18
- (s/def ::binding-form
19
- (s/or :local-symbol ::local-name
20
- :seq-destructure ::seq-binding-form
21
- :map-destructure ::map-binding-form))
22
-
23
- ;; sequential destructuring
24
-
25
- (s/def ::seq-binding-form
26
- (s/and vector?
27
- (s/cat :forms (s/* ::binding-form)
28
- :rest-forms (s/? (s/cat :ampersand #{'&} :form ::binding-form))
29
- :as-form (s/? (s/cat :as #{:as} :as-sym ::local-name)))))
30
-
31
- ;; map destructuring
32
-
33
- (s/def ::non-binding-elements (s/cat :ampersand #{'&} ::non-binding-element (s/+ any?)))
34
- (s/def ::keys-form (s/and vector? (s/cat :bindings (s/* ident?) :nonbinding (s/? ::non-binding-elements))))
35
- (s/def ::syms-form (s/and vector? (s/cat :bindings (s/* symbol?) :nonbinding (s/? ::non-binding-elements))))
36
- (s/def ::simple-syms-form (s/and vector? (s/cat :bindings (s/* simple-symbol?) :nonbinding (s/? ::non-binding-elements))))
37
-
38
- (s/def ::keys ::keys-form)
39
- (s/def ::syms ::syms-form)
40
- (s/def ::strs ::simple-syms-form)
41
- (s/def ::keys! ::keys-form)
42
- (s/def ::syms! ::syms-form)
43
- (s/def ::strs! ::simple-syms-form)
44
- (s/def ::or map?)
45
- (s/def ::as ::local-name)
46
- (s/def ::defaults ::local-name)
47
- (s/def ::select ::local-name)
48
- (s/def ::excess ::local-name)
49
- (s/def ::missing ::local-name)
50
- (s/def ::all ::local-name)
51
-
52
- (s/def ::map-special-binding
53
- (s/keys :opt-un [::as ::or ::keys ::syms ::strs ::keys! ::syms! ::strs! ::select ::excess ::missing ::defaults ::all]))
54
-
55
- (s/def ::map-binding (s/tuple ::binding-form any?))
56
-
57
- (s/def ::ns-keys
58
- (s/tuple
59
- (s/and qualified-keyword? #(-> % name #{"keys" "syms" "keys!" "syms!"}))
60
- ::simple-syms-form))
61
-
62
- (s/def ::map-bindings
63
- (s/every (s/or :map-binding ::map-binding
64
- :qualified-keys-or-syms ::ns-keys
65
- :special-binding (s/tuple #{:as :or :keys :syms :strs :keys! :syms! :strs! :select :excess :missing :defaults :all} any?))
66
- :kind map?))
67
-
68
- (s/def ::map-binding-form (s/merge ::map-bindings ::map-special-binding))
69
-
70
- ;; bindings
71
-
72
- (defn even-number-of-forms?
73
- "Returns true if there are an even number of forms in a binding vector"
74
- [forms]
75
- (even? (count forms)))
76
-
77
- (s/def ::binding (s/cat :form ::binding-form :init-expr any?))
78
- (s/def ::bindings (s/and vector? even-number-of-forms? (s/* ::binding)))
79
-
80
- ;; let, if-let, when-let
81
-
82
- (s/fdef core/let
83
- :args (s/cat :bindings ::bindings
84
- :body (s/* any?)))
85
-
86
- (s/fdef core/if-let
87
- :args (s/cat :bindings (s/and vector? ::binding)
88
- :then any?
89
- :else (s/? any?)))
90
-
91
- (s/fdef core/when-let
92
- :args (s/cat :bindings (s/and vector? ::binding)
93
- :body (s/* any?)))
94
-
95
- ;; defn, defn-, fn
96
-
97
- (s/def ::param-list
98
- (s/and
99
- vector?
100
- (s/cat :params (s/* ::binding-form)
101
- :var-params (s/? (s/cat :ampersand #{'&} :var-form ::binding-form)))))
102
-
103
- (s/def ::params+body
104
- (s/cat :params ::param-list
105
- :body (s/alt :prepost+body (s/cat :prepost map?
106
- :body (s/+ any?))
107
- :body (s/* any?))))
108
-
109
- (s/def ::defn-args
110
- (s/cat :fn-name simple-symbol?
111
- :docstring (s/? string?)
112
- :meta (s/? map?)
113
- :fn-tail (s/alt :arity-1 ::params+body
114
- :arity-n (s/cat :bodies (s/+ (s/spec ::params+body))
115
- :attr-map (s/? map?)))))
116
-
117
- (s/fdef core/defn
118
- :args ::defn-args
119
- :ret any?)
120
-
121
- (s/fdef core/defn-
122
- :args ::defn-args
123
- :ret any?)
124
-
125
- (s/fdef core/fn
126
- :args (s/cat :fn-name (s/? simple-symbol?)
127
- :fn-tail (s/alt :arity-1 ::params+body
128
- :arity-n (s/+ (s/spec ::params+body))))
129
- :ret any?)
130
-
131
- ;;;; ns
132
-
133
- (s/def ::exclude (s/coll-of simple-symbol?))
134
- (s/def ::only (s/coll-of simple-symbol?))
135
- (s/def ::rename (s/map-of simple-symbol? simple-symbol?))
136
- (s/def ::filters (s/keys* :opt-un [::exclude ::only ::rename]))
137
-
138
- (s/def ::ns-refer-clojure
139
- (s/spec (s/cat :clause #{:refer-clojure}
140
- :refer-filters ::filters)))
141
-
142
- (s/def ::refer (s/coll-of simple-symbol?))
143
- (s/def ::refer-macros (s/coll-of simple-symbol?))
144
- (s/def ::include-macros #{true})
145
-
146
- (s/def ::lib (s/or :sym simple-symbol?
147
- :str string?))
148
-
149
- (s/def ::libspec
150
- (s/alt :lib ::lib
151
- :lib+opts (s/spec (s/cat :lib ::lib
152
- :options (s/keys* :opt-un [::as ::refer ::refer-macros ::include-macros])))))
153
-
154
- (s/def ::macros-libspec
155
- (s/alt :lib simple-symbol?
156
- :lib+opts (s/spec (s/cat :lib simple-symbol?
157
- :options (s/keys* :opt-un [::as ::refer])))))
158
-
159
- (s/def ::ns-require
160
- (s/spec (s/cat :clause #{:require}
161
- :body (s/+ (s/alt :libspec ::libspec
162
- :flag #{:reload :reload-all :verbose})))))
163
-
164
- (s/def ::ns-require-macros
165
- (s/spec (s/cat :clause #{:require-macros}
166
- :body (s/+ (s/alt :libspec ::macros-libspec
167
- :flag #{:reload :reload-all :verbose})))))
168
-
169
- (s/def ::package-list
170
- (s/spec
171
- (s/cat :package simple-symbol?
172
- :classes (s/+ simple-symbol?))))
173
-
174
- (s/def ::import-list
175
- (s/* (s/alt :class simple-symbol?
176
- :package-list ::package-list)))
177
-
178
- (s/def ::ns-import
179
- (s/spec
180
- (s/cat :clause #{:import}
181
- :classes ::import-list)))
182
-
183
- ;; same as ::libspec, but also supports the ::filters options in the libspec
184
- (s/def ::use-libspec
185
- (s/alt :lib ::lib
186
- :lib+opts (s/spec (s/cat :lib ::lib
187
- :options (s/keys* :req-un [::only] :opt-un [::rename])))))
188
-
189
- (s/def ::ns-use
190
- (s/spec (s/cat :clause #{:use}
191
- :libs (s/+ (s/alt :libspec ::use-libspec
192
- :flag #{:reload :reload-all :verbose})))))
193
-
194
- ;; same as ::libspec-macros, but also supports the ::filters options in the libspec
195
- (s/def ::use-macros-libspec
196
- (s/alt :lib simple-symbol?
197
- :lib+opts (s/spec (s/cat :lib simple-symbol?
198
- :options (s/keys* :req-un [::only] :opt-un [::rename])))))
199
-
200
- (s/def ::ns-use-macros
201
- (s/spec (s/cat :clause #{:use-macros}
202
- :libs (s/+ (s/alt :libspec ::use-macros-libspec
203
- :flag #{:reload :reload-all :verbose})))))
204
-
205
- (s/def ::ns-refer-global
206
- (s/spec (s/cat :clause #{:refer-global}
207
- :options (s/keys* :req-un [::only]))))
208
-
209
- (s/def ::ns-require-global
210
- (s/spec (s/cat :clause #{:require-global}
211
- :body (s/+ ::libspec))))
212
-
213
- (s/def ::ns-clauses
214
- (s/* (s/alt
215
- :refer-clojure ::ns-refer-clojure
216
- :require ::ns-require
217
- :require-macros ::ns-require-macros
218
- :import ::ns-import
219
- :use ::ns-use
220
- :use-macros ::ns-use-macros
221
- :refer-global ::ns-refer-global
222
- :require-global ::ns-require-global)))
223
-
224
- (s/def ::ns-form
225
- (s/cat :ns-name simple-symbol?
226
- :docstring (s/? string?)
227
- :attr-map (s/? map?)
228
- :ns-clauses ::ns-clauses))
229
-
230
- (s/fdef core/ns-special-form
231
- :args ::ns-form)
232
-
233
- (defn- quoted
234
- "Returns a spec that accepts a (quote ...) form of the spec"
235
- [spec]
236
- (s/spec (s/cat :quote #{'quote} :spec spec)))
237
-
238
- (s/def ::quoted-import-list
239
- (s/* (s/alt :class (quoted simple-symbol?)
240
- :package-list (quoted ::package-list))))
241
-
242
- (s/fdef core/import
243
- :args ::quoted-import-list)
244
-
245
- (s/fdef core/require
246
- :args (s/+ (s/alt :libspec (quoted ::libspec)
247
- :flag #{:reload :reload-all :verbose})))
248
-
249
- (s/fdef core/require-macros
250
- :args (s/+ (s/alt :libspec (quoted ::macros-libspec)
251
- :flag #{:reload :reload-all :verbose})))
252
-
253
- (s/fdef core/use
254
- :args (s/+ (s/alt :libspec (quoted ::use-libspec)
255
- :flag #{:reload :reload-all :verbose})))
256
-
257
- (s/fdef core/use-macros
258
- :args (s/+ (s/alt :libspec (quoted ::use-macros-libspec)
259
- :flag #{:reload :reload-all :verbose})))
260
-
261
- (comment
262
-
263
- (s/valid? ::ns-refer-global
264
- '(:refer-global :only [Date] :rename {Date MyDate}))
265
-
266
- (s/valid? ::ns-refer-global
267
- '(:refer-global :only))
268
-
269
- (s/valid? ::ns-require-global
270
- '(:require-global [jquery :as jq :refer [carousel] :rename {carousel car}]))
271
-
272
- )