@zntc/web 0.1.1 → 0.1.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/dist/inject.d.ts CHANGED
@@ -12,6 +12,21 @@ export interface BundleResult {
12
12
  export declare function injectIntoDevHtml(outdir: string, build: (html: string) => string | null): void;
13
13
  /** `<script type="module" src="/__zntc_app_dev_hmr__"></script>` 를 head 에 1회 삽입. */
14
14
  export declare function injectAppDevHmrClient(outdir: string): void;
15
+ /**
16
+ * React Fast Refresh preamble `<script src="/__zntc_react_refresh__"></script>` 를 1회 삽입.
17
+ * ⚠️ **첫 `<script` 앞**에 넣는다 — classic(non-module) 스크립트라 파싱 중 동기 실행되어
18
+ * `injectIntoGlobalHook(window)` 가 React 를 import 하는 (deferred) module 스크립트보다 *먼저*
19
+ * 끝나야 reconciler 패치가 유효하다. injectIntoDevHtml(=`</head>` 앞 삽입)을 안 쓰는 이유.
20
+ */
21
+ export declare function injectAppDevReactRefreshPreamble(outdir: string): void;
15
22
  export declare function injectAppDevBundleCssLinks(outdir: string, base: string | undefined, bundleResult: BundleResult | null | undefined): void;
23
+ /**
24
+ * #3813 — outdir 의 `.css` 파일을 file system 스캔해 HTML `<link>` 주입. `injectAppDevBundleCssLinks`
25
+ * 가 `bundleResult.outputFiles` 를 받는 것과 달리 file system 기반. caller (`runServe`) 가
26
+ * native watch onRebuild 에서 호출 — bundleResult 가 없는 graphChanged 경로의 stale link 회귀
27
+ * 가드. outdir 의 first-level `*.css` 만 스캔 (chunk subdirectory 미포함 — bundler 의 entry_names
28
+ * `[dir]/[name]` default 가 emit 한 결과 위치 기준).
29
+ */
30
+ export declare function injectAppDevBundleCssLinksFromOutdir(outdir: string, base: string | undefined): void;
16
31
  export declare function injectAppDevPipelineCssLinks(outdir: string, base: string | undefined, cssRelPaths: readonly string[]): void;
17
32
  export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * react-refresh 런타임 소스를 글로벌 바인딩 + injectIntoGlobalHook 으로 감싼 preamble 문자열.
3
+ * - react-refresh 설치됨 → 실제 preamble.
4
+ * - react 는 있으나 react-refresh 없음 → noop + 설치 경고(=React 앱인데 FR 못 켬).
5
+ * - react 도 없음 → `null`(비-React 앱 — 호출자가 주입/서빙 스킵, 경고 없음).
6
+ * @param rootDir 앱 루트(여기 node_modules 기준으로 resolve).
7
+ */
8
+ export declare function buildReactRefreshPreamble(rootDir: string): string | null;
@@ -38,12 +38,44 @@ interface ConfigEnv {
38
38
  * `fallbackRequire` 는 caller 의 CLI context — postcss/postcss-load-config 를
39
39
  * app 이 갖지 않을 때 fallback (e.g. ZNTC CLI 의 node_modules).
40
40
  */
41
- export declare function loadPostcssConfig(root: string, configEnv: ConfigEnv, fallbackRequire: NodeRequire): Promise<LoadedPostcss | null>;
41
+ export declare function loadPostcssConfig(root: string, configEnv: ConfigEnv, fallbackRequire: NodeRequire,
42
+ /** issue #3857 /code-review max #1 — postcss / postcss-load-config 의
43
+ * require base. config search 가 monorepo root 인 경우에도 module require
44
+ * 는 app root 가 정상 (pnpm strict / nohoist 환경에서 monorepo root 에
45
+ * postcss 미설치 가능). 미지정 시 root 인자 사용 — 기존 동작 유지. */
46
+ requireBase?: string): Promise<LoadedPostcss | null>;
42
47
  /**
43
48
  * `cssDir` 의 모든 CSS 파일 (skipDir 제외) 에 postcss 실행 → in-place 덮어쓰기.
44
49
  * postcss config 가 없으면 no-op. `runPostcssForAppDev` 와 달리 outdir 분리 안 함.
50
+ *
51
+ * `override` 가 truthy 면 자동 발견 skip — 사용자 explicit `plugins: [css({
52
+ * postcss: {...override} })]` 의 caller-side pre-warm path (RFC #3833 v3 D1a'').
53
+ * Vite parity: `override.plugins` 가 빈 배열이어도 explicit no-op 으로 처리
54
+ * (auto-discover 로 fallback 안 함). `postcss` 자체는 동일 fallback chain 으로
55
+ * require — 미설치 시 logLevel != silent 면 warn 출력 후 skip (override path
56
+ * 가 silently no-op 안 되도록 가시성 확보).
45
57
  */
46
- export declare function runPostcssIfConfigured(root: string, cssDir: string, skipDir: string | null, configEnv: ConfigEnv, logLevel: string | undefined, fallbackRequire: NodeRequire): Promise<void>;
58
+ export interface RunPostcssIfConfiguredResult {
59
+ /** issue #3850 — PostCSS message 의 dep tracking. tailwind @source 등의
60
+ * file dependency. caller (prepareAppCssPipelineRoot) 가 보존 후 dev path
61
+ * 의 skipPostcssRun 가 watch trigger 정합 위해 사용. */
62
+ deps: Set<string>;
63
+ /** issue #3850 — PostCSS message 의 dir-dep tracking. tailwind v4 의
64
+ * @source "../html" 같은 directory watch. */
65
+ dirDeps: Set<string>;
66
+ }
67
+ export declare function runPostcssIfConfigured(root: string, cssDir: string, skipDir: string | null, configEnv: ConfigEnv, logLevel: string | undefined, fallbackRequire: NodeRequire, override?: {
68
+ plugins: unknown[];
69
+ options?: Record<string, unknown>;
70
+ /** issue #3851 — css({root}) 의 root override. postcss module require 의
71
+ * base. 미지정 시 root 인자 사용. */
72
+ root?: string;
73
+ } | null,
74
+ /** issue #3857 — css({root}) 단독 명시 시 auto-discover path 의 search base.
75
+ * override 없을 때 loadPostcssConfig(cssAutoDiscoverRoot ?? root) 로 호출 →
76
+ * postcss.config 가 monorepo root 에 있고 app 이 sub-package 인 시나리오 cover.
77
+ * 미지정 시 root 인자 사용 — 기존 동작 유지. */
78
+ cssAutoDiscoverRoot?: string | null): Promise<RunPostcssIfConfiguredResult>;
47
79
  export interface AppDevPostcssOptions {
48
80
  root: string;
49
81
  outdir: string;
@@ -52,6 +84,28 @@ export interface AppDevPostcssOptions {
52
84
  base: string | undefined;
53
85
  changedPath?: string | null;
54
86
  fallbackRequire: NodeRequire;
87
+ /** caller-side pre-warm 으로 전달되는 PostCSS override (RFC #3833 v3 D1a''
88
+ * Phase 2). build path 의 `runPostcssIfConfigured` 와 동일 시맨틱 — truthy
89
+ * 면 자동발견 skip, plugins.length === 0 면 explicit no-op. issue #3851:
90
+ * root override 도 routing (postcss require base). */
91
+ postcssOverride?: {
92
+ plugins: unknown[];
93
+ options?: Record<string, unknown>;
94
+ root?: string;
95
+ } | null;
96
+ /** dev path zero-config double-pass 회피 (issue #3847). controller 의
97
+ * prepare 가 PostCSS 처리 (auto-discover 또는 override) 했음을 caller 가
98
+ * 알린 경우 true — runPostcssForAppDev 가 PostCSS 호출 skip + sourceRoot
99
+ * 의 .css 를 outdir 로 mirror (PostCSS 미적용, 이미 처리된 결과 그대로).
100
+ * cssDeps 는 raw root path 로 유지 (watch trigger 정합). */
101
+ skipPostcssRun?: boolean;
102
+ /** skipPostcssRun=true 시 mirror 의 source root (prepare 의 tempRoot 또는
103
+ * raw root). 미지정 시 root 사용. controller 가 pipelineRoot 전달. */
104
+ sourceRoot?: string;
105
+ /** issue #3857 — auto-discover path 의 findPostcssConfig/loadPostcssConfig
106
+ * search base. monorepo edge: app 이 sub-package, postcss.config 가
107
+ * monorepo root. 미지정 시 root 인자 사용. */
108
+ cssAutoDiscoverRoot?: string | null;
55
109
  }
56
110
  export interface AppDevPostcssResult {
57
111
  deps: Set<string>;
@@ -9,6 +9,9 @@ interface SassCompileOptions {
9
9
  }
10
10
  interface SassCompileResult {
11
11
  css: string;
12
+ /** dart-sass 가 컴파일에 사용한 전이 @import/@use URL 목록(자기 자신 포함). dev watch 의
13
+ * reverse-dep 추적용 — partial(`_x.scss`) 변경 시 이를 import 한 root scss 를 재컴파일 (#71). */
14
+ loadedUrls?: URL[];
12
15
  }
13
16
  export declare const CSS_PREPROCESSOR_EXTENSIONS: ReadonlySet<string>;
14
17
  export declare function isCssPreprocessorFile(path: string): boolean;
@@ -40,6 +43,9 @@ export interface TransformCssPreprocessorOptions {
40
43
  dirtyOnly?: ReadonlySet<string> | null;
41
44
  /** dirty source files — `rewriteSassReferences` 의 대상 한정. null 이면 sourceFiles 전체. */
42
45
  dirtySources?: readonly string[] | null;
46
+ /** 컴파일한 파일별 전이 @import/@use 의존(loadedUrls)을 보고하는 콜백. dev watch 가
47
+ * reverse-dep 맵을 구축해 partial 변경 시 root scss 를 재컴파일하는 데 쓴다 (#71). */
48
+ onDeps?: (file: string, loadedUrls: readonly URL[]) => void;
43
49
  }
44
50
  /**
45
51
  * `files` (Sass/SCSS 입력) 를 컴파일해 같은 path 의 `.css` + `.css.js` proxy 생성.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zntc/web",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "ZNTC web platform — dev server + HMR overlay + postcss/sass pipeline + dev controller",
5
5
  "keywords": [
6
6
  "bundler",
@@ -35,21 +35,25 @@
35
35
  ".": {
36
36
  "types": "./dist/index.d.ts",
37
37
  "import": "./dist/index.js"
38
+ },
39
+ "./css": {
40
+ "types": "./dist/css/index.d.ts",
41
+ "import": "./dist/css/index.js"
38
42
  }
39
43
  },
40
44
  "scripts": {
41
- "build:bundle": "node ../core/bin/zntc.mjs --bundle src/index.ts --outfile dist/index.js --format=esm --target=node --conditions=source --external @zntc/core --external postcss --external postcss-load-config --external sass",
45
+ "build:bundle": "node ../core/bin/zntc.mjs --bundle src/index.ts --outfile dist/index.js --format=esm --target=node --conditions=source --external @zntc/core --external postcss --external postcss-load-config --external sass && node ../core/bin/zntc.mjs --bundle src/css/index.ts --outfile dist/css/index.js --format=esm --target=node --conditions=source --external @zntc/core --external postcss --external postcss-load-config --external sass && node -e \"require('node:fs').copyFileSync('runtime/dev-overlay-client.raw.js','dist/dev-overlay-client.raw.js')\"",
42
46
  "build:dts": "bun x tsc -b",
43
47
  "build": "bun run build:bundle && bun run build:dts",
44
48
  "test": "bun test --timeout 10000",
45
- "prepublishOnly": "bun run build && bunx publint --strict --level error ."
49
+ "prepublishOnly": "bun run build && node -e \"require('node:fs').statSync('dist/dev-overlay-client.raw.js')\" && bunx publint --strict --level error ."
46
50
  },
47
51
  "dependencies": {
48
- "@zntc/core": "0.1.1"
52
+ "@zntc/core": "0.1.2"
49
53
  },
50
54
  "devDependencies": {
51
55
  "@types/node": "^25.5.2",
52
- "@zntc/server": "0.1.1"
56
+ "@zntc/server": "0.1.2"
53
57
  },
54
58
  "optionalDependencies": {
55
59
  "postcss": "^8.5.8",